Android SeekBar的使用
16lz
2021-01-23
Android SeekBar的使用
转载自:http://aina-hk55hk.iteye.com/blog/677254
<?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("拖动完毕"); } }
更多相关文章
- Android 两个可拖动的SeekBar 两点拖动
- Android 开发技巧之 手动拖动滚动条快速滑动
- Android——导入已存在的android工程时出现红叉错误“AndroidMan
- android的大好时光结束进行时
- 【Android】Android控件之Seekbar拖动条的使用
- Android ListView 去除边缘阴影、选中色、拖动背景色等
- android手动拖动滚动条快速滑动
- c语句以句号结束对吗