开发者

how to make a seek bar to get moved automatically in an android app

开发者 https://www.devze.com 2023-03-04 02:52 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号