1、代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SeekBar seekbar=(SeekBar)findViewById(R.id.seekBar1);
final TextView textview =(TextView)findViewById(R.id.textView1);
seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "停止滑动", Toast.LENGTH_SHORT).show();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
Toast.makeText(MainActivity.this, "开始滑动", Toast.LENGTH_SHORT).show();// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
textview.setText("当前值:"+progress);// TODO Auto-generated method stub
}
});
}
效果如下