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拖动条控件的更多相关文章

  1. Android 拖动条/滑动条控件、星级评分控件

    ProgressBar有2个子控件: SeekBar   拖动条控件 RatingBar   星级评分控件 1.拖动条控件 <SeekBar android:layout_width=" ...

  2. Android自定义Seekbar拖动条式样

    SeekBar拖动条可以由用户控制,进行拖动操作.比如,应用程序中用户需要对音量进行控制,就可以使用拖动条来实现. 1.SeekBar控件的使用 1.1SeekBar常用属性 SeekBar的常用属性 ...

  3. HslControls组件库 工业控件库 曲线控件 时间控件 管道控件 温度计控件 阀门控件 传送带控件 进度条控件 电池控件 数码管控件等等

    本篇博客主要对 HslControls 组件做一个大概的总览介绍,更详细的内容可以参照页面里的子链接,还有github上的源代码,然后进行相关的学习,和使用. Prepare 先从nuget下载到组件 ...

  4. C# 根据BackgroundWoker异步模型和ProgressBar控件,自定义进度条控件

    前言 程序开发过程中,难免会有的业务逻辑,或者算法之类产生让人能够感知的耗时操作,例如循环中对复杂逻辑处理;获取数据库百万乃至千万级数据;http请求的时候等...... 用户在使用UI操作并不知道程 ...

  5. WEB进度条控件

    近段时间为了工作的需要学习了一下写自定义控件,呵呵!以前没写过,近段时间才开始研究的,昨天写了一个WEB状态条控件,可以设置进度条的百分比,也可以设置它的总数与当前的数量来自动计算百分比,可以设置颜色 ...

  6. Photoshop和WPF双剑配合,打造炫酷个性的进度条控件

    现在如果想打造一款专业的App,UI的设计和操作的简便性相当重要.UI设计可以借助Photoshop或者AI等设计工具,之前了解到WPF设计工具Expression Blend可以直接导入PSD文件或 ...

  7. [转载]ExtJs4 笔记(8) Ext.slider 滚轴控件、 Ext.ProgressBar 进度条控件、 Ext.Editor 编辑控件

    作者:李盼(Lipan)出处:[Lipan] (http://www.cnblogs.com/lipan/)版权声明:本文的版权归作者与博客园共有.转载时须注明本文的详细链接,否则作者将保留追究其法律 ...

  8. 用 CALayer 定制下载进度条控件

    // // RPProgressView.h // CALayer定制下载进度条控件 // // Created by RinpeChen on 16/1/2. // Copyright © 2016 ...

  9. ExtJs4 笔记(8) Ext.slider 滚轴控件、 Ext.ProgressBar 进度条控件、 Ext.Editor 编辑控件

    本篇要登场的有三个控件,分别是滚轴控件.进度条控件和编辑控件. 一.滚轴控件 Ext.slider 1.滚轴控件的定义 下面我们定义三个具有代表意义滚轴控件,分别展示滚轴横向.纵向,以及单值.多值选择 ...

随机推荐

  1. 修改/etc/hosts 云服务器 没有做外网转内网的优化

    [root@a mapReduceLog]# scp /data/visitlog/* root@d:/data/mapReduceVisitorLog/a/root@d's password:vis ...

  2. Universally Unique Identifier amazonservices API order 亚马逊订单接口的分析 NextToken

    one hour in linux mysql> ) from listorders; +----------+ | count() | +----------+ | | +---------- ...

  3. WCF引用 代码

    方法1: using (ChannelFactory<ICommonService> channelFactory = new ChannelFactory<ICommonServi ...

  4. django-Query Ajax 实例 ($.ajax、$.post、$.get)

    Jquery在异步提交方面封装的很好,直接用AJAX非常麻烦,Jquery大大简化了我们的操作,不用考虑浏览器的诧异了. 推荐一篇不错的jQuery Ajax 实例文章,忘记了可以去看看,地址为:ht ...

  5. Git学习笔记-完全版

    注意本文参考廖雪博客: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 一:Git ...

  6. 如何根据一些参数,自动生成一个简单的maven工程,然后导入Eclipse直接使用?(maven命令)

    1. 使用mvn archetype:generate命令 2. 选择archetype类型:(默认是org.apache.maven.archetypes:maven-archetype-quick ...

  7. nginx限制连接

    limit_conn_zone $binary_remote_addr zone=addr:10m; locaton /download { limit_rate_after 128k; #是对每个连 ...

  8. python之路 JavaScript基础

    一.JavaScript简介 JavaScript一种直译式脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型.它的解释器被称为JavaScript引擎,为 浏览器的一部分,广泛用于客户端 ...

  9. html基础 CSS样式表

    CSS(Cascading Style Sheet,叠层样式表),作用是美化HTML网页. /*注释区域*/此为注释语法 一.样式表 (一)样式表的分类 1.内联样式表 和HTML联合显示,控制精确, ...

  10. $python正则表达式系列(6)——"或"表达式的用法

    import re s1 = u'距离地铁5号线189米' s2 = u'距离地铁5号线(环中线)189米' s3 = u'距离地铁5号线(环中线)189米' p1 = re.compile(u'号线 ...