SeekBar拖动条控件
SeekBar拖动条控件
一、简介
1、

二、SeekBar拖动条控件使用方法
1、创建SeekBar控件
<SeekBar
android:id="@+id/SeekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="30"
/>
2、添加setOnSeekBarChangeListener监听
seekBar2.setOnSeekBarChangeListener(this);
三、代码实例
1、效果图:

2、代码
fry.Activity01
package fry; import com.example.SeekBarDemo1.R; 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 Activity01 extends Activity implements OnSeekBarChangeListener{
private TextView textView1;
private TextView textView2;
private SeekBar seekBar1;
private SeekBar seekBar2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity01);
textView1=(TextView) findViewById(R.id.TextView1_seekBar);
textView2=(TextView) findViewById(R.id.TextView2_seekBar);
seekBar1=(SeekBar) findViewById(R.id.SeekBar1);
seekBar2=(SeekBar) findViewById(R.id.SeekBar2);
seekBar1.setOnSeekBarChangeListener(this);
seekBar2.setOnSeekBarChangeListener(this);
}
/*
* onProgressChanged:进度条改变事件
* onStartTrackingTouch:进度条开始拖动事件
* onStopTrackingTouch:进度条停止拖动事件
* (non-Javadoc)
* @see android.widget.SeekBar.OnSeekBarChangeListener#onProgressChanged(android.widget.SeekBar, int, boolean)
*/
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
if(seekBar1.getId()==R.id.SeekBar1){
Toast.makeText(this, "1111111", Toast.LENGTH_SHORT).show();
textView1.setText("seekBar1当前位置:"+progress);
}else{
textView2.setText("seekBar2当前位置:"+progress);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
if(seekBar1.getId()==R.id.SeekBar1){
textView1.setText("seekBar1开始拖动");
}else{
textView2.setText("seekBar2开始拖动:");
}
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
if(seekBar1.getId()==R.id.SeekBar1){
textView1.setText("seekBar1停止拖动");
}else{
textView2.setText("seekBar2停止拖动:");
}
}
}
/SeekBarDemo1/res/layout/activity01.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:id="@+id/TextView1_seekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView1"
/>
<TextView
android:id="@+id/TextView2_seekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView2"
/> <SeekBar
android:id="@+id/SeekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="30"
/> <SeekBar
android:id="@+id/SeekBar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="60"
/> </LinearLayout>
四、获得
1、设置初始进度条
android:progress="30"
2、设置setOnSeekBarChangeListener监听
seekBar1.setOnSeekBarChangeListener(this);
3、onProgressChanged:进度条改变事件
4、onStartTrackingTouch:进度条开始拖动事件
5、onStopTrackingTouch:进度条停止拖动事件
SeekBar拖动条控件的更多相关文章
- Android 拖动条/滑动条控件、星级评分控件
ProgressBar有2个子控件: SeekBar 拖动条控件 RatingBar 星级评分控件 1.拖动条控件 <SeekBar android:layout_width=" ...
- Android自定义Seekbar拖动条式样
SeekBar拖动条可以由用户控制,进行拖动操作.比如,应用程序中用户需要对音量进行控制,就可以使用拖动条来实现. 1.SeekBar控件的使用 1.1SeekBar常用属性 SeekBar的常用属性 ...
- HslControls组件库 工业控件库 曲线控件 时间控件 管道控件 温度计控件 阀门控件 传送带控件 进度条控件 电池控件 数码管控件等等
本篇博客主要对 HslControls 组件做一个大概的总览介绍,更详细的内容可以参照页面里的子链接,还有github上的源代码,然后进行相关的学习,和使用. Prepare 先从nuget下载到组件 ...
- C# 根据BackgroundWoker异步模型和ProgressBar控件,自定义进度条控件
前言 程序开发过程中,难免会有的业务逻辑,或者算法之类产生让人能够感知的耗时操作,例如循环中对复杂逻辑处理;获取数据库百万乃至千万级数据;http请求的时候等...... 用户在使用UI操作并不知道程 ...
- WEB进度条控件
近段时间为了工作的需要学习了一下写自定义控件,呵呵!以前没写过,近段时间才开始研究的,昨天写了一个WEB状态条控件,可以设置进度条的百分比,也可以设置它的总数与当前的数量来自动计算百分比,可以设置颜色 ...
- Photoshop和WPF双剑配合,打造炫酷个性的进度条控件
现在如果想打造一款专业的App,UI的设计和操作的简便性相当重要.UI设计可以借助Photoshop或者AI等设计工具,之前了解到WPF设计工具Expression Blend可以直接导入PSD文件或 ...
- [转载]ExtJs4 笔记(8) Ext.slider 滚轴控件、 Ext.ProgressBar 进度条控件、 Ext.Editor 编辑控件
作者:李盼(Lipan)出处:[Lipan] (http://www.cnblogs.com/lipan/)版权声明:本文的版权归作者与博客园共有.转载时须注明本文的详细链接,否则作者将保留追究其法律 ...
- 用 CALayer 定制下载进度条控件
// // RPProgressView.h // CALayer定制下载进度条控件 // // Created by RinpeChen on 16/1/2. // Copyright © 2016 ...
- ExtJs4 笔记(8) Ext.slider 滚轴控件、 Ext.ProgressBar 进度条控件、 Ext.Editor 编辑控件
本篇要登场的有三个控件,分别是滚轴控件.进度条控件和编辑控件. 一.滚轴控件 Ext.slider 1.滚轴控件的定义 下面我们定义三个具有代表意义滚轴控件,分别展示滚轴横向.纵向,以及单值.多值选择 ...
随机推荐
- 科学计算 NumPy 与C语言对比 N-dimensional array ndarray 元素元素操作 计算正太分布分位数
w http://www.numpy.org/ NumPy is the fundamental package for scientific computing with Python. It co ...
- Cookie 入门
位于 javax.servlet.http 包下 1. HTTP 协议与 Cookie 关于 Cookie Cookie 是 HTTP 协议制定的!先由服务器保存 Cookie 到浏览器, 在下次浏览 ...
- IO 流之字节流和转换流
基本读取操作: InputStream(); OutputStream(); // 直接写入目的地中, 不需要 flush() 刷新 write(byte[] b); // 参数为 byte 数组 字 ...
- 搞懂head 和 tail 命令
情景 会点linux命令的人都知道head -n k和tail -n k(k≥0)的作用,但却不知道还支持head -n -k和tail -n +k的用法, 更不知道有着怎样的作用了. 图解 下面,用 ...
- maven安装,maven命令行使用
1 下载maven,解压(无需安装),配置环境变量,命令行mvn -v测试. 2 maven常用命令:https://www.cnblogs.com/wkrbky/p/6352188.html 3 注 ...
- php socket 处理只是来数据流,该怎样避免(好像是堵塞了)
php socket 处理只是来数据流,该怎样处理(好像是堵塞了) 需求:php接受一个硬件往8888port上发送数据,假设收到后,应socket_send函数返回"\xFA\x01\x0 ...
- Tomcat WEB站点部署
上线的代码有两种方式, 第一种方式是直接将程序目录放在webapps目录下面 第二种方式是使用开发工具将程序打包成war包,然后上传到webapps目录下面.下面让我们见识一下这种方式 这个网站里面已 ...
- redis的图形化工具(四)
1. 介绍 本篇会介绍几个关于redis的图形化的监控工具和管理工具. 2. redis-stat redis-stat提供终端和web端的监控页面,它安装和使用起来很简单. 安装只需要一条指令. $ ...
- pycharm修改配置
恢复pycharm的初始设置
- MySQL-5.7 存储过程及函数
1.语法 CREATE [DEFINER = { user | CURRENT_USER }] PROCEDURE sp_name ([proc_parameter[,...]]) [characte ...