Android—进度条
layout文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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.hanqi.testapp2.TestActivity4"
android:orientation="vertical"> <ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:progress="0"
android:secondaryProgress="0"
android:max="80"
android:id="@+id/pb_1"/>
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleLarge"
android:id="@+id/pb_2"/>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="0"
android:max="80"
android:secondaryProgress="0"
android:id="@+id/se_1"/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:rating="3.5"
android:isIndicator="true"/>
</LinearLayout>
java类代码:
package com.hanqi.testapp2; import android.app.AlertDialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.SeekBar; public class TestActivity4 extends AppCompatActivity { SeekBar se_1;
ProgressBar pb_1;
ProgressBar pb_2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test4);
se_1 = (SeekBar)findViewById(R.id.se_1);
pb_1 = (ProgressBar)findViewById(R.id.pb_1);
pb_2 = (ProgressBar)findViewById(R.id.pb_2); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); se_1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
//进度变化触发
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//设置进度条1的进度值
pb_1.setProgress(progress);
//判断是否达到最大值
if(progress ==se_1.getMax())
{
pb_2.setVisibility(View.INVISIBLE);//不显示但位置还保留
}
else
{
pb_2.setVisibility(View.VISIBLE);
}
//只要progress变化就会触发
//Toast.makeText(TestActivity4.this, "当前进度 = "+progress, Toast.LENGTH_SHORT).show();
} @Override
public void onStartTrackingTouch(SeekBar seekBar) {
Log.e("TAG","进度条开始拖动");
} @Override
public void onStopTrackingTouch(SeekBar seekBar) {
Log.e("TAG","进度条停止拖动");
}
});
}
}
效果为:



Android—进度条的更多相关文章
- 多种的android进度条的特效源码
多种的android进度条的特效源码,这个源码是在源码天堂那个网站上转载过来的,我已经修改一部分了,感觉很实用的,大家可以学习一下吧,我就不上传源码了,大家可以直接到那个网站上下载吧. 源码天堂下载地 ...
- android进度条
android进度条 1.达到的效果 2.布局代码 先写一个my_browser.xml文件 存放WebView <?xml version="1.0" encoding=& ...
- Android 进度条改变图片透明度
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Android 进度条
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Android——进度条ProgressBar
1.activity_progressbar.xml <?xml version="1.0" encoding="utf-8"?><Linea ...
- android进度条的使用
// 导入按钮事件 btnsearch.setOnClickListener(new View.OnClickListener() { @Override public void on ...
- Android 进度条按钮实现(ProgressButton)
有些App在点击下载按钮的时候,可以在按钮上显示进度,我们可以通过继承原生Button,重写onDraw来实现带进度条的按钮. Github:https://github.com/imcloudflo ...
- Android 进度条对话框ProgressDialog
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Android进度条控件ProgressBar使用
ProgressBar有四种样式,圆形的(大,中,小)和直条形的(水平) 对应的style为 <LinearLayout xmlns:android="http://schemas.a ...
随机推荐
- 关于oc运行时 isa指针详解
Cocoa框架是iOS应用程序的基础,了解Cocoa框架,对开发iOS应用有很大的帮助. 1.Cocoa是什么? Cocoa是OS X和 iOS操作系统的程序的运行环境. 是什么因素使一个程序成为Co ...
- [转]powerDesigner生成excel版本的数据库文件
powerDesigner生成excel版本的数据库文件 出处:http://ray-allen.iteye.com/blog/1893347 脚本 excel 今天收到一个需求,要把数据库设计给一 ...
- Hibernate4 No Session found for current thread原因
Hibernate4 与 spring3 集成之后, 如果在取得session 的地方使用了getCurrentSession, 可能会报一个错:“No Session found for curre ...
- shell变量的使用
转载请标明http://www.cnblogs.com/winifred-tang94/ shell环境中变量有三种类型: a. 环境变量:可以在shell脚本中直接利用“$环境变量名称”的形式引用 ...
- iphone获取当前运行进程列表
通过调用 sys/sysctl.h 读取系统内核获取进程列表 . 代码悦德财富:https://yuedecaifu.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 ...
- Setup Factory 打包.netframework 2.0
在setup factory 的安装目录下的Dependencies中新建目录dotnet20/并放入dotnetfx2.0.exe: Dependencies目录中再加xml文件dotnet20.x ...
- UIlabel设置不同的颜色
NSString *string = @"注册过程中出现问题,致电400-650-5167联系会养车工作人员"; NSRange range = [string rangeO ...
- 分析一个嵌入payload的恶意.lnk文件
原文:https://isc.sans.edu/diary/Analyzis+of+a+Malicious+.lnk+File+with+an+Embedded+Payload/20763 We re ...
- Java 嵌套作用域
在C/C++中,当一个块处于另一个块作用域内的时候,内层定义的变量会把外层的变量隐藏, 遵循所谓的就近原则. 在Java中,在内层定义与外层同名的变量是禁止的! 如下: int i = 0; for( ...
- linux基础命令学习五(软件包管理、下载管理)
Linux 软件包管理 本文主要是记录下RedHat系列的软件包管理. 内容分为以下二个部分:二进制包的管理,源代码包的管理 一.二进制包的管理 1.1概念 主要有RPM和YUM这两种包管理. 两 ...