ProgressBar进度条示例
2016-08-25 10:37
197 查看
//ProgressBar示例 ------------- MainActivity.java -------------- package com.example.gby.s01_e17_progressbar; import android.content.DialogInterface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CompoundButton; import android.widget.ProgressBar; public class MainActivity extends AppCompatActivity { private ProgressBar progressBar; private Button firstButton; private Button secondButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progressBar = (ProgressBar)findViewById(R.id.firstProgressBar);//找对象 firstButton = (Button)findViewById(R.id.firstButton);//找对象 secondButton = (Button)findViewById(R.id.secondButton);//找对象 progressBar.setMax(100); firstButton.setOnClickListener(new FirstListener());//必须new个对象 secondButton.setOnClickListener(new SecondListener());//必须new个对象 // boolean flag = progressBar.isIndeterminate();//是 非精确的,就是转圈的进度条 // progressBar.incrementProgressBy(10);//增量进度 // progressBar.incrementSecondaryProgressBy(10); } class FirstListener implements View.OnClickListener{ @Override public void onClick(View view) { progressBar.incrementProgressBy(10); } } class SecondListener implements View.OnClickListener{ @Override public void onClick(View view) { progressBar.incrementSecondaryProgressBy(20); } } }
--------------- activity_main.xml ---------------- <?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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" tools:context="com.example.gby.s01_e17_progressbar.MainActivity"> <ProgressBar android:id="@+id/firstProgressBar" android:layout_width="match_parent" android:layout_height="wrap_content" style="?android:attr/progressBarStyleHorizontal" /> <Button android:id="@+id/firstButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/firstProgressBar" android:text="增加第一进度" /> <Button android:id="@+id/secondButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/firstButton" android:text="增加第二进度" /> </RelativeLayout>
相关文章推荐
- SWT中多线程(Thread)控制进度(ProgressBar)条示例
- Android编程实现自定义ProgressBar样式示例(背景色及一级、二级进度条颜色)
- android基本控件示例progressbar进度条(03)
- C#组件设计技术兼谈带百分比进度条组件TSmartProgressBar的实现
- 圆弧矩形进度条,可用于在layout或者imageview外层实现进度的显示(改良android-square-progressbar)
- 玩转Andorid---UI篇---两种进度条(ProgressBar)
- silverlight漂亮的文件上传进度显示原理及示例
- Android--进度条--ProgressBar--SeekBar
- android 各种进度条(ProgressBar)
- Android自定义进度条(ProgressBar)的问题
- Android-RoundCornerProgressBar——Android圆角进度条(Progress Bar)类库
- progressbar用于制作类似进度条
- ProgressBar进度条
- 带进度的progressBar
- Android ProgressBar ImageLoading 旋转进度值
- Android之利用Handler实现ProgressBar进度条
- bootstrap+jQuery实现的动态进度条功能示例
- Android 显示或隐藏标题栏进度条TitleProgressBar
- ProgressBar 水平进度条(初步)
- asp.net利用多线程执行长时间的任务,客户端显示出任务的执行进度的示例