滑动条DEMO
java部分
private SeekBar sb;
private TextView result;
result=(TextView)findViewById(R.id.tv);
sb =(SeekBar)findViewById(R.id.sb);
sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "滑动结束", Toast.LENGTH_LONG).show();
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "滑动开始", Toast.LENGTH_LONG).show();
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
result.setText("当前值:"+progress);
// TODO Auto-generated method stub
}
});
xml部分
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="当前值:50"/>
<SeekBar
android:id="@+id/sb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:max="100"
android:progress="50"
/>
效果图