in my app i want to place a seek bar.开发者_运维问答 i want the seek bar to be move by its own as like in the media player a bar to show the remaining duration of the song.
When the user start to move from one location to the other, i am calculating the distance that the user traveling from one place to the other. So in order to show visualization i am trying to show the seek bar.
Is there any other layout for this....
Can anyone give me some example......
SeekBar extends ProgressBar, so you can set its position as you would with a ProgressBar. BTW, if you only need to visualize the distance, use a ProgressBar.
With ProgressBar.setMax() you set the top value, with ProgressBar.setProgress() you set the current value.
public void seek updater()
{
if(media.isPlaying())
{
SeekBar s=(SeekBar)findViewById(R.id.seek);
s.setProgress(m.getCurrentPosition());
Runnable r=new Runnable()
{
@Override
public void run() {
seekupdater();
}
};
new Handler().postDelayed(r,1000);
}
}
just create a method like the above and call it when u press the play button. i found this http://www.hrupin.com/2010/12/simple-android-mp3-media-player very interesting,this may also help to find your answer.
加载中,请稍侯......
精彩评论