Android SeekBar的使用
Android SeekBar的使用
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <SeekBar android:id="@+id/SeekBar01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:max="100" android:progress="50" android:secondaryProgress="100"></SeekBar> <TextView android:id="@+id/TextView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" /> <TextView android:id="@+id/TextView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" /> </LinearLayout>
package com.Aina.Android; import android.app.Activity; import android.os.Bundle; import android.widget.SeekBar; import android.widget.TextView; public class Test_SeekBar extends Activity implements SeekBar.OnSeekBarChangeListener{ /** Called when the activity is first created. */ private SeekBar seekBar; private TextView textView1,textView2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); seekBar = (SeekBar) this.findViewById(R.id.SeekBar01); textView1 = (TextView) this.findViewById(R.id.TextView1); textView2 = (TextView) this.findViewById(R.id.TextView2); seekBar.setOnSeekBarChangeListener(this);//添加事件监听 } //拖动中 @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { this.textView1.setText("当前值:"+progress); } //开始拖动 @Override public void onStartTrackingTouch(SeekBar seekBar) { this.textView2.setText("拖动中..."); } //结束拖动 @Override public void onStopTrackingTouch(SeekBar seekBar) { this.textView2.setText("拖动完毕"); } }
相关推荐
zhonglinzhang 2012-06-05
ffnercn 2012-05-06
mpqitmp 2012-03-05
Drabandon 2014-09-30
jsxin0 2014-01-16
moira 2013-11-08
najiutan 2013-05-03
qinxu 2012-08-03
Tom天天 2012-04-26
zhaazha 2011-11-03
Nostalgiachild 2011-09-15
AndroidGA 2011-09-02
androidty 2011-05-12
virusplayer 2010-12-24
Liuser 2010-10-14
yuemeng0 2010-07-12
冰川孤辰 2010-05-21