Android程序:使用SeekBar实现滑动进度条功能
来源:互联网 发布:淘宝仅退款不退货规则 编辑:程序博客网 时间:2024/06/06 03:45
代码实现:
MainActivity :
public class MainActivity extends Activity implements OnSeekBarChangeListener { private SeekBar seekBar; private TextView tv1; private TextView tv2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv1=(TextView) findViewById(R.id.tv1); tv2=(TextView) findViewById(R.id.tv2); seekBar=(SeekBar) findViewById(R.id.seekbar); seekBar.setOnSeekBarChangeListener(this); } //数值改变调用 @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { tv1.setText("正在拖动"); tv2.setText("当前进度:"+progress); } //开始拖动调用 @Override public void onStartTrackingTouch(SeekBar seekBar) { tv1.setText("开始拖动"); } //停止拖动调用 @Override public void onStopTrackingTouch(SeekBar seekBar) { tv1.setText("停止拖动"); }}
Layout :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.seekbardemo.MainActivity" > <SeekBar android:id="@+id/seekbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:max="100" android:progress="50" /> <TextView android:id="@+id/tv2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignLeft="@+id/seekbar" android:layout_below="@+id/seekbar" /> <TextView android:id="@+id/tv1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignLeft="@+id/tv2" android:layout_below="@+id/tv2" /></RelativeLayout>
0 0
- Android程序:使用SeekBar实现滑动进度条功能
- Android-SeekBar可滑动进度条
- Android百度音乐滑动进度条SeekBar
- Android-SeekBar进度条的使用
- android SeekBar(带滑动块的进度条)的应用举例
- 手动滑动的进度条 SeekBar
- android 自定义进度条 seekbar
- android 自定义进度条 seekbar
- Android-SeekBar(拖动进度条)
- Android--进度条--ProgressBar--SeekBar
- seekBar实现滑动解锁
- android Seekbar双滑块滑动
- 【Android】SeekBar禁止滑动
- android三档自定义滑动开关,禁止点击功能的实现,用默认的seekbar组件实现
- Android程序:使用ViewFlipper实现屏幕切换动画及手势滑动切换功能
- android中SeekBar拖动进度条的使用及事件监听
- android中SeekBar拖动进度条的使用及事件监听
- Android 可拖动的进度条:SeekBar之简单使用
- #leetcode#Candy
- IBM---Java 多线程与并发编程专题
- 【Leetcode Algorithm】Roman to Integer
- IM消息的显示方法和装置-专利
- 总结:接口、类、抽象类、继承、构造函数、方法重写、方法重载、自动转型、多态、引用传递
- Android程序:使用SeekBar实现滑动进度条功能
- c# lock
- Linux线程-互斥锁pthread_mutex_t
- Expression is not assignable
- android开发网络资源
- JSON.parse和eval的区别
- 【Leetcode Algorithm】Reverse Linked List
- iOS中对时间的处理(一)——获取当前时间戳
- PLSQL下复制表/将一张表插入另一张表中/连接两张表