Android SeekBar的使用,androidseekbar
投稿于 被查看 32503 次 评论:43
Android SeekBar的使用,androidseekbar
SeekBar拖动条的使用1.layout
<?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>
2.Test_SeekBar.java
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("拖动完毕"); } }
用户评论