SeekBar拖动条,是Progress的间接子类
1 <SeekBar 2 android:id="@+id/seekBar1" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:progress="30" 6 //Draws the thumb on a seekbar. 7 android:thumb="@drawable/peasy" />
SeekBar事件,被拉动时,onProgressChanged会一直被触发
1 public void showSeekBar() { 2 seekBar = (SeekBar) findViewById(R.id.seekBar1); 3 seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { 4 5 @Override 6 public void onStopTrackingTouch(SeekBar seekBar) { 7 // TODO Auto-generated method stub 8 Log.i(TAG, "onStopTrackingTouch"); 9 Toast.makeText(FormActivity.this, 10 "current level is " + seekBar.getProgress(), 3000) 11 .show(); 12 } 13 14 @Override 15 public void onStartTrackingTouch(SeekBar seekBar) { 16 // TODO Auto-generated method stub 17 Log.i(TAG, "onStartTrackingTouch"); 18 19 } 20 21 @Override 22 public void onProgressChanged(SeekBar seekBar, int progress, 23 boolean fromUser) { 24 // TODO Auto-generated method stub 25 Log.i(TAG, "onProgressChanged"); 26 27 } 28 }); 29 }