Android SeekBar 拖动条 滑动条
来源:互联网 发布:js 数组转对象 编辑:程序博客网 时间:2024/05/16 08:39
作者:Virgo_S
SeekBar是ProgressBar的一个子类,下面我们用一个可以改变并显示当前进度的拖动条例子来演示一下它的使用:
1、main.xml
2、java:
3、运行程序:
1、main.xml
- <?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="245px"
- android:layout_height="25px" android:paddingLeft="16px"
- android:paddingRight="15px" android:paddingTop="5px"
- android:paddingBottom="5px" android:progress="0" android:max="0"
- android:secondaryProgress="0" />
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/hello"
- android:id="@+id/TextView01" />
- </LinearLayout>
2、java:
- package com.esri.arcgis.sample;
- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.SeekBar;
- import android.widget.SeekBar.OnSeekBarChangeListener;
- import android.widget.TextView;
- import android.widget.Toast;
- public class AndroidSeekBar extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- // 找到拖动条和文本框
- final SeekBar sb = (SeekBar) findViewById(R.id.SeekBar01);
- final TextView tv1 = (TextView) findViewById(R.id.TextView01);
- // 设置拖动条的初始值和文本框的初始值
- sb.setMax(100);
- sb.setProgress(30);
- tv1.setText("当前进度:" + sb.getProgress());
- // 设置拖动条改变监听器
- OnSeekBarChangeListener osbcl = new OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress,
- boolean fromUser) {
- tv1.setText("当前进度:" + sb.getProgress());
- Toast.makeText(getApplicationContext(), "onProgressChanged",
- Toast.LENGTH_SHORT).show();
- }
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- Toast.makeText(getApplicationContext(), "onStartTrackingTouch",
- Toast.LENGTH_SHORT).show();
- }
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- Toast.makeText(getApplicationContext(), "onStopTrackingTouch",
- Toast.LENGTH_SHORT).show();
- }
- };
- // 为拖动条绑定监听器
- sb.setOnSeekBarChangeListener(osbcl);
- }
- }
3、运行程序:
0 0
- Android SeekBar 拖动条 滑动条
- android 拖动条 SeekBar
- Android SeekBar拖动条
- android 拖动条(SeekBar)
- android SeekBar 拖动条
- Android:拖动条SeekBar
- Android SeekBar拖动条
- Android SeekBar(拖动条)
- android---拖动条(SeekBar)
- android 自定义SeekBar(拖动条)
- android 控件 拖动条(SeekBar)
- android 垂直拖动条seekbar
- Android---31---SeekBar拖动条
- Android练习-----拖动条(SeekBar)
- Android自定义SeekBar滑动条
- 拖动条(SeekBar)
- [控件]SeekBar拖动条
- 拖动条(seekbar)
- VC修改用户密码
- jfreechart 画柱状图
- MySQL数据类型详解
- JS转换HTML转义符
- Macbook pro连接无线路由不稳定掉线的解决办法
- Android SeekBar 拖动条 滑动条
- Cocos2d-x 类COC手游与RTS(即时战略)游戏的编程实践总结
- BOM头的处理
- Objective-c中的内存管理的黄金法则,OC中最重要的部分
- (亲测兼容360、IE、谷歌、火狐等浏览器)鼠标悬停显示页面被截取字段的全部内容
- hdu 5017 ellipsoid 退火大法
- android中sd卡常用状态
- swift,函数
- dom4j解析xml