SeekBar拖动条

1./TestSeekBar/res/layout/main.xml:

 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent"
6 >
7 <SeekBar
8 android:id="@+id/seekbar01"
9 android:layout_width="fill_parent"
10 android:layout_height="wrap_content"
11 android:max="100"
12 android:progress="50"
13 android:secondaryProgress="75"
14 />
15 <TextView
16 android:id="@+id/textview01"
17 android:layout_width="fill_parent"
18 android:layout_height="wrap_content"
19 />
20 <TextView
21 android:id="@+id/textview02"
22 android:layout_width="fill_parent"
23 android:layout_height="wrap_content"
24 />
25 </LinearLayout>

 

2. TestSeekBarAcitivty:

 

 1 import android.app.Activity;
2 import android.os.Bundle;
3 import android.widget.SeekBar;
4 import android.widget.TextView;
5 import android.widget.SeekBar.OnSeekBarChangeListener;
6
7 public class TestSeekBarAcitivty extends Activity implements OnSeekBarChangeListener
8 {
9 private SeekBar seekbar;
10 private TextView textView01;
11 private TextView textView02;
12 @Override
13 public void onCreate(Bundle savedInstanceState)
14 {
15 super.onCreate(savedInstanceState);
16 setContentView(R.layout.main);
17 seekbar = (SeekBar) findViewById(R.id.seekbar01);
18 seekbar.setOnSeekBarChangeListener(this);
19 textView01 = (TextView) findViewById(R.id.textview01);
20 textView02 = (TextView) findViewById(R.id.textview02);
21 }
22 @Override
23 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch)
24 {
25 textView01.setText("当前值:"+progress);
26 }
27 @Override
28 public void onStartTrackingTouch(SeekBar arg0)
29 {
30 textView02.setText("正在调解");
31 }
32 @Override
33 public void onStopTrackingTouch(SeekBar arg0)
34 {
35 textView02.setText("停止调解");
36 }
37 }

 

3.效果图:




posted @ 2011-10-30 15:31  程序学习笔记  阅读(4265)  评论(1编辑  收藏  举报