Код:
package ua.dominqnta.dubstepgun;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
int track = 0;
MediaPlayer mediaPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button switch_t = (Button) findViewById(R.id.button1);
OnClickListener oclswitch = new OnClickListener(){
@SuppressWarnings("deprecation")
@SuppressLint("CutPasteId")
@Override
public void onClick(View arg0) {
track++;
if(track==1)
{
mediaPlayer = MediaPlayer.create(this, R.raw.industrial);
}
if(track==2)
{
mediaPlayer = MediaPlayer.create(this, R.raw.one);
}
if(track==3)
{
mediaPlayer = MediaPlayer.create(this, R.raw.meet_the_presedent);
}
if(track==4)
{
mediaPlayer = MediaPlayer.create(this, R.raw.four);
}
if(track==5)
{
mediaPlayer = MediaPlayer.create(this, R.raw.five);
}
}
};
switch_t.setOnClickListener(oclswitch);
}
}
Ошибка в mediaPlayer = MediaPlayer.create(this, R.raw.one); : The method create(Context, int) in the type MediaPlayer is not applicable for the arguments (new View.OnClickListener(){}, int)
Вопрос задан
более трёх лет назад
2428 просмотров