Android如何使用SeekBar
activity_mian.xml 部分
seek.xml
package?com.example.administrator.seekbar; import?android.support.v7.app.ActionBarActivity; import?android.os.Bundle; import?android.view.Menu; import?android.view.MenuItem; import?android.widget.SeekBar; import?android.widget.TextView; public?class?MainActivity?extends?ActionBarActivity?{ ????private?SeekBar?seekBar; ????private?TextView?text1; ????private?TextView?text2; ????@Override ????protected?void?onCreate(Bundle?savedInstanceState)?{ ????????super.onCreate(savedInstanceState); ????????setContentView(R.layout.activity_main); ????????seekBar?=?(SeekBar)findViewById(R.id.seekBar); ????????text1?=?(TextView)findViewById(R.id.text1); ????????text2?=?(TextView)findViewById(R.id.text2); ????????seekBar.setOnSeekBarChangeListener(new?SeekBar.OnSeekBarChangeListener()?{ ????????????@Override ????????????public?void?onProgressChanged(SeekBar?seekBar,?int?progress,?boolean?fromUser)?{ ????????????????text1.setText("正在拖動(dòng)"); ????????????????text2.setText("當(dāng)前數(shù)值:"+progress); ????????????} ????????????@Override ????????????public?void?onStartTrackingTouch(SeekBar?seekBar)?{ ????????????????text1.setText("開始拖動(dòng)"); ????????????} ????????????@Override ????????????public?void?onStopTrackingTouch(SeekBar?seekBar)?{ ????????????????text1.setText("停止拖動(dòng)"); ????????????} ????????}); ????} }