@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);無法解析方法TimeUnit行
b1 = (Button) findViewById(R.id.button);
b2 = (Button) findViewById(R.id.button2);
b3 = (Button) findViewById(R.id.button3);
b4 = (Button) findViewById(R.id.button4);
iv = (ImageView) findViewById(R.id.imageView);
tx1 = (TextView) findViewById(R.id.textView2);
tx2 = (TextView) findViewById(R.id.textView3);
tx3 = (TextView) findViewById(R.id.textView4);
tx3.setText("song.mp3");
mediaPlayer = MediaPlayer.create(this, R.raw.song);
seekBar = (SeekBar) findViewById(R.id.seekBar);
seekBar.setClickable(false);
b2.setEnabled(false);
b3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Playing Now", Toast.LENGTH_LONG).show();
mediaPlayer.start();
finalTime = mediaPlayer.getDuration();
startTime = mediaPlayer.getCurrentPosition();
if (oneTimeOnly == 0){
seekBar.setMax((int) finalTime);
oneTimeOnly = 1;
}
/* Problem below line */
tx2.setText(String.format("%d min, %d sec",
TimeUnit.MILLISECOND.toMinutes((long) finalTime),
TimeUnit.MILLISECONDS.toMinutes((long) finalTime) -
TimeUnit.MINUTE.toSeconds(TimeUnit.MILLISECONDS.toMinutes())));
}
});
}
它的顯示無法解析方法,文本是紅色。我已應用Alt + Enter但不起作用。如何解決它。
什麼是父類...? – MordechayS
無法理解 –
您正在嘗試使用哪種方法? – MordechayS