The only way to do this is with a handler as mentioned a few times
above already.
On Mar 31, 12:41 pm, Phision <kali...@gmail.com> wrote:
I think I have the same problem. I want to update a progress bar at a
regular interval of time. I am calling setProgress() each second but
the progress bar will not redraw itself.
I tried to call postInvalidate after setProgress and it works BUT only
if I give a constant value to setProgress (for example
setProgress(14)). When I give the value I want (which is one media
player's position) it does not redraw itself
I see that I shall try the approach, mentioned here - with handlers -
but anyway is there anyone that can explain me why this happens?
Here is my code of the timer:
public class KalinTask extends TimerTask {
private TrackProgress p;
private MediaPlayer mp;
public KalinTask(TrackProgress _p, MediaPlayer _mp){
p = _p; mp = _mp;
p.setProgress(5);
}
@Override
public void run() {
Log.e("upl", "Run: "+ p.getProgress());
p.setProgress((mp.getCurrentPosition()*100)/mp.getDuration());
p.postInvalidate();
}
}