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—进度条的更多相关文章

  1. 多种的android进度条的特效源码

    多种的android进度条的特效源码,这个源码是在源码天堂那个网站上转载过来的,我已经修改一部分了,感觉很实用的,大家可以学习一下吧,我就不上传源码了,大家可以直接到那个网站上下载吧. 源码天堂下载地 ...

  2. android进度条

    android进度条 1.达到的效果 2.布局代码 先写一个my_browser.xml文件 存放WebView <?xml version="1.0" encoding=& ...

  3. Android 进度条改变图片透明度

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  4. Android 进度条

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  5. Android——进度条ProgressBar

    1.activity_progressbar.xml <?xml version="1.0" encoding="utf-8"?><Linea ...

  6. android进度条的使用

    // 导入按钮事件  btnsearch.setOnClickListener(new View.OnClickListener() {      @Override   public void on ...

  7. Android 进度条按钮实现(ProgressButton)

    有些App在点击下载按钮的时候,可以在按钮上显示进度,我们可以通过继承原生Button,重写onDraw来实现带进度条的按钮. Github:https://github.com/imcloudflo ...

  8. Android 进度条对话框ProgressDialog

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  9. Android进度条控件ProgressBar使用

    ProgressBar有四种样式,圆形的(大,中,小)和直条形的(水平) 对应的style为 <LinearLayout xmlns:android="http://schemas.a ...

随机推荐

  1. 构建者模式(Builder)示例代码

    package com.test; /** * Created by xiaonanhai on 2015/5/30. */ public class Builder { private String ...

  2. PL/SQL

    function & procedure packages function --> arguments or parameters with arguments, IN, read o ...

  3. new 动态分配数组空间

    (一)定义一个整数              int *p =new int;        int *p =new int(4); //赋初值4 (二)定义一个一维数组                ...

  4. 获取手机联系人项目 PPGetAddressBook

    PPGetAddressBook PPGetAddressBook对AddressBook框架(iOS9之前)和Contacts框架(iOS9之后)做了对应的封装处理; 支持获取按联系人姓名首字拼音A ...

  5. SQL优化-索引

    (一)深入浅出理解索引结构 实际上,您可以把索引理解为一种特殊的目录.微软的SQL SERVER提供了两种索引:聚集索引(clustered index,也称聚类索引.簇集索引)和非聚集索引(nonc ...

  6. 重拾java系列一java基础(3)

    这一章主要复习下以前所接触的算法, (1)选择排序法:在要排序的一组数中,选出最小的一个数与第一个位置的数交换:然后在剩下的数当中再找最小的与第二个位置的数交换,如此循环到倒数第二个数和最后一个数比较 ...

  7. 12-26 tableView的学习心得

    一:基础部分 UITableView的两种样式: 注意是只读的 1.UITableViewStytlePlain(不分组的) n 2.UITableViewStyleGrouped(分组的) 二:如何 ...

  8. PHP Forms

    <html><body><form action="welcome.php" method="post">Name: < ...

  9. 安装webmin

    wget http://nchc.dl.sourceforge.net/project/webadmin/webmin/1.740/webmin-1.740.tar.gz 解压缩文件,命令是:tar ...

  10. 解决:子元素设置margin-top,父元素也受影响的问题

    <!doctype html><html> <head> <meta charset="UTF-8"> <title>子 ...