Android 无论我尝试什么,Seekbar 都不更新
Android Seekbar does not update no matter what I try
Seekbar 没有更新,不确定是活页夹还是其他问题。我放弃了。
我试过timer, runnable,就是不更新。我不确定这是我的错还是搜索栏,我不知道。我放弃了,我只想问问 Whosebug 上的人,看看你们是否能帮助我。我已经在这个问题上花费了 4 个多小时,它只会减慢我可以做的其他事情。
这是我为 Runnable 写的:
public void run() {
//int curr = player.mediaPlayer.getCurrentPosition();
try {
//why the dirty code?
//seekbar.setprogress did not work for me
//it refuses to update it's position
//i have no idea why and i have no time to look into it.
//I was throwing everything at the problem at this point.
Log.v("Service Bound", Integer.toString(curr));
Toast.makeText(MainActivity.this, "Service Bound!", Toast.LENGTH_LONG).show();
songStat.setProgress(0);
songStat.setMax(player.mediaPlayer.getDuration());
songStat.setProgress(100);
curr++;
}catch(Exception e){
}
}
};
handler.postDelayed(r, 100);
您在初始化 Handler 时是否尝试过此操作,这将 运行 您的代码放在主线程上,
Handler handler = new Handler(Looper.getMainLooper());
Seekbar 没有更新,不确定是活页夹还是其他问题。我放弃了。
我试过timer, runnable,就是不更新。我不确定这是我的错还是搜索栏,我不知道。我放弃了,我只想问问 Whosebug 上的人,看看你们是否能帮助我。我已经在这个问题上花费了 4 个多小时,它只会减慢我可以做的其他事情。 这是我为 Runnable 写的:
public void run() {
//int curr = player.mediaPlayer.getCurrentPosition();
try {
//why the dirty code?
//seekbar.setprogress did not work for me
//it refuses to update it's position
//i have no idea why and i have no time to look into it.
//I was throwing everything at the problem at this point.
Log.v("Service Bound", Integer.toString(curr));
Toast.makeText(MainActivity.this, "Service Bound!", Toast.LENGTH_LONG).show();
songStat.setProgress(0);
songStat.setMax(player.mediaPlayer.getDuration());
songStat.setProgress(100);
curr++;
}catch(Exception e){
}
}
};
handler.postDelayed(r, 100);
您在初始化 Handler 时是否尝试过此操作,这将 运行 您的代码放在主线程上,
Handler handler = new Handler(Looper.getMainLooper());