在m中使用android seekbar with play和剩余时间为songprgress处理程序的线程以下示例代码。每当我点击下一首/上一首歌曲时,它会显示大整数值。如何解决这个问题?seekbar播放时间和剩余时间显示大整数值。
class SongProgressUpdateThread extends Thread {
public void run() {
if (mp != null) {
int currentPosition = 0;
int total = mp.getDuration();
while (currentPosition < total && mp.isPlaying() && stopSongProgressThread==false) {
try {
Thread.sleep(500);
currentPosition = mp.getCurrentPosition();
} catch (InterruptedException e) {
return;
} catch (Exception e) {
return;
}
songProgress.setProgress(currentPosition);
showProgress(currentPosition, total);
}
}
}
}
private void showProgress(int currentPosition, int duration) {
Bundle bundle = new Bundle();
bundle.putString("playedTime", getPlayedTime(currentPosition));
bundle.putString("remainingTime",getRemainigTime(currentPosition, duration));
Message msg = new Message();
msg.setData(bundle);
songProgresshandler.sendMessage(msg);
}
Handler songProgresshandler = new Handler() {
public void handleMessage(Message message) {
final Bundle b = message.getData();
playedTime.setText(b.getString("playedTime"));
remainingTime.setText("-" + b.getString("remainingTime"));
}
};
请粘贴您的getPlayedTime()和getRemainingTime实现 – jeet
请注意,您可以[将行格式化为代码](http://meta.stackexchange.com/questions/22186/)缩进四个空格。编辑器工具栏中的“{}”按钮可以为您做到这一点。编辑你的问题并尝试一下。单击编辑器工具栏中的橙色问号以获取更多信息和格式化提示。 – outis
请用请求的代码更新问题。一般而言,通过更新您的帖子来回应澄清请求,而不是回复评论。首先,如果没有阅读评论,一个问题应该是可以理解的。另一方面,SO是一个质量保证和网站,而不是一个论坛,评论意图不适合(也不适合)讨论。 – outis