AndroidGUI07:SeekBar的常用技巧
来源:互联网 发布:mysql 修改复合主键 编辑:程序博客网 时间:2024/05/01 05:08
SeekBar其实也是一种ProgressBar,它是ProgressBar的间接派生类,因此ProgressBar可以用的方法,SeekBar都可以用。
1. 在布局文件(main.xml)中,增加界面元素声明如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<SeekBar
android:id="@+id/seekbar"
android:layout_width="240px"
android:layout_height="wrap_content"
android:max="500"
/>
<TextView
android:id="@+id/seekbar_tv"
android:layout_width="80px"
android:layout_height="wrap_content"
android:text=""
/>
</LinearLayout>
2. Activity所对应的代码:
public class ControlSeekBar extends Activity
implements
OnSeekBarChangeListener
{
private SeekBar sb;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
sb =(SeekBar)findViewById(R.id.seekbar);
sb.setOnSeekBarChangeListener(this);
sb.setProgress(100);
}
public voidonProgressChanged(SeekBar sb, int progress, boolean fromUser)
{
((TextView)findViewById(R.id.seekbar_tv)).setText(" " +progress);
}
public voidonStartTrackingTouch(SeekBar seekBar)
{
//Notification that the user has started a touch gesture.
// Clientsmay want to use this to disable advancing the seekbar.
}
public voidonStopTrackingTouch(SeekBar seekBar)
{
//Notification that the user has finished a touch gesture.
// Clientsmay want to use this to re-enable advancing the seekbar.
}
}
运行结果:
拖动thumb之前:
拖动thumb到400处:
- AndroidGUI07:SeekBar的常用技巧
- Android常用控件之SeekBar的使用
- Android常用控件之SeekBar的使用
- Android常用控件之:SeekBar
- SeekBar的使用和竖向的SeekBar
- 【SeekBar】Android 自定义漂亮的SeekBar样式
- CSS的常用技巧
- CSS的常用技巧
- CSS的常用技巧
- 常用的网页技巧
- CSS的常用技巧
- javascript的常用技巧
- c#常用的技巧
- VI 的常用技巧
- javascript常用的技巧
- CSS的常用技巧
- 常用的JS技巧
- Spinner的常用技巧
- 百万级PHP网站架构工具箱
- 多少傻逼为红颜, 多少红颜不要脸
- hdoj1009FatMouse' Trade(贪心求解)
- linux驱动理论专拦
- 在浏览器右键添加自定义菜单
- AndroidGUI07:SeekBar的常用技巧
- 传统模拟摄像机发展之路:向左走,向右走?
- 精摘语录
- GDB使用命令
- QT学习 第一章:基本对话框--各种信息框的使用
- android HTTP 通信, XML 解析, 通过 Hander 实现异步消息处理 (1)
- ffmpeg relocation error
- android HTTP 通信, XML 解析, 通过 Hander 实现异步消息处理(2)
- NoSQL 数据库 简介