SeekBar的用法

作者: android_Pie | 来源:发表于2020-03-13 17:51 被阅读0次

    1)ProgressBar (一般进度条,例如:下载进度条)
    2)SeekBar(拖动条,适用于音乐,视频播放进度条)
    3)RatingBar(星星数量级别评价条)

    public class MainActivity extends Activity implements OnSeekBarChangeListener{
    
        private SeekBar sBar;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            sBar=(SeekBar) findViewById(R.id.seekBar1);
            sBar.setOnSeekBarChangeListener(this);
        }
    
        /**进度改变时执行此方法*/
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromUser) {
            Log.i("TAG", "onProgressChanged");
        }
    
        /**按下(开始触摸)seekBar时*/
        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            int startProgress=
            seekBar.getProgress();
            Log.i("TAG", "startProgress="+startProgress);
        }
    
        /**抬起(停止触摸)seekBar时*/
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            int stopProgress=
            seekBar.getProgress();
            Log.i("TAG", "stopProgress="+stopProgress);
        }
    }
    
    
    QQ群号172660439.png

    相关文章

      网友评论

        本文标题:SeekBar的用法

        本文链接:https://www.haomeiwen.com/subject/swxsshtx.html