- public class MainActivity extends AppCompatActivity {
- private SeekBar seekbar=null;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- seekbar = (SeekBar) findViewById(R.id.seekbar_01);
- seekbar.setMax(100);
- seekbar.setProgress(30);
- seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
- Log.v("拖动过程中的值:", String.valueOf(progress) + ", " + String.valueOf(fromUser));
- }
- @Override
- public void onStartTrackingTouch(SeekBar seekbar) {
- Log.v("开始滑动时的值:", String.valueOf(seekbar.getProgress()));
- }
- @Override
- public void onStopTrackingTouch(SeekBar seekbar) {
- Log.v("停止滑动时的值:", String.valueOf(seekbar.getProgress()));
- }
- });
读取seekbar的值
最新推荐文章于 2023-04-14 23:56:06 发布