【转】【Android】ProgressDialog进度条对话框的使用
Android ProgressDialog进度条对话框的使用:
转自:http://aina-hk55hk.iteye.com/blog/679134/
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/hello" />
- <Button android:text="圆形进度条" android:id="@+id/Button01"
- android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <Button android:text="长型进度条" android:id="@+id/Button02"
- android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- </LinearLayout>
- package com.Aina.Android;
- import android.app.Activity;
- import android.app.ProgressDialog;
- import android.content.DialogInterface;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- public class Test_ProgressDialog extends Activity {
- /** Called when the activity is first created. */
- private ProgressDialog mpDialog;
- private Button btn1,btn2;
- private int mCount = 0;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- btn1 = (Button) this.findViewById(R.id.Button01);
- btn2 = (Button) this.findViewById(R.id.Button02);
- btn1.setOnClickListener(new OnClickListener(){
- @Override
- public void onClick(View v) {
- mpDialog = new ProgressDialog(Test_ProgressDialog.this);
- mpDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);//设置风格为圆形进度条
- mpDialog.setTitle("提示");//设置标题
- mpDialog.setIcon(R.drawable.icon);//设置图标
- mpDialog.setMessage("这是一个圆形进度条");
- mpDialog.setIndeterminate(false);//设置进度条是否为不明确
- mpDialog.setCancelable(true);//设置进度条是否可以按退回键取消
- mpDialog.setButton("确定", new DialogInterface.OnClickListener(){
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
- mpDialog.show();
- }
- });
- btn2.setOnClickListener(new OnClickListener(){
- @Override
- public void onClick(View v) {
- mCount = 0;
- mpDialog = new ProgressDialog(Test_ProgressDialog.this);
- mpDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- mpDialog.setTitle("提示");
- mpDialog.setIcon(R.drawable.icon);
- mpDialog.setMessage("这是一个长型进度条");
- mpDialog.setMax(100);
- mpDialog.setProgress(0);
- mpDialog.setSecondaryProgress(50);
- mpDialog.setIndeterminate(false);
- mpDialog.setCancelable(true);
- mpDialog.setButton("取消", new DialogInterface.OnClickListener(){
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
- new Thread(){
- public void run(){
- try{
- while(mCount<=100){
- mpDialog.setProgress(mCount++);
- Thread.sleep(100);
- }
- mpDialog.cancel();
- }catch(Exception ex){
- mpDialog.cancel();
- }
- }
- }.start();
- mpDialog.show();
- }
- });
- }
- }
【转】【Android】ProgressDialog进度条对话框的使用的更多相关文章
- Android——ProgressDialog 进度条对话框
public class ProgressDialogActivity extends Activity { private Button btn_large_pd, btn_horizonta ...
- android学习笔记20——ProgressDialog进度条对话框
ProgressDialog==>进度条对话框 ProgressDialog本身就代表一个进度条对话框,程序只需要创建ProgressDialog实例,并将其显示出来就是一个进度条对话框:开发者 ...
- 【转】24. android dialog ——ProgressDialog 进度条对话框详解
原文网址:http://blog.csdn.net/jamesliulyc/article/details/6375598 首先在onCreateDialog方法里创建一个ProgressDialog ...
- ProgressDialog进度条对话框
(一) 1.效果图: 2.activity_main.xml <?xml version="1.0" encoding="utf-8"?> < ...
- Android开发 ---构建对话框Builder对象,消息提示框、列表对话框、单选提示框、多选提示框、日期/时间对话框、进度条对话框、自定义对话框、投影
效果图: 1.activity_main.xml 描述: a.定义了一个消息提示框按钮 点击按钮弹出消息 b.定义了一个选择城市的输入框 点击按钮选择城市 c.定义了一个单选提示框按钮 点击按钮选择某 ...
- Android 进度条对话框ProgressDialog
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- 025 Android 带进度条的对话框(ProgressDialog)
1.ProgressDialog介绍 ProgressDialog可以在当前界面弹出一个置顶于所有界面元素的对话框,同样具有屏蔽其他控件的交互能力,用于提示用户当前操作正在运行,让用户等待: 2.应用 ...
- Android Studio常见对话框(普通对话框、单选对话框、多选对话框、进度条对话框、消息对话框、自定义对话框)
Android Studio常见对话框(普通对话框.单选对话框.多选对话框.进度条对话框.消息对话框.自定义对话框) 1.普通对话框 2.单选对话框 3.多选对话框 4.进度条对话框 5.消息对话框 ...
- ProgressWheelDialogUtil【ProgressWheel Material样式进度条对话框】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 简单封装网络请求时的加载对话框以及上传.下载文件的进度加载对话框. 效果图 代码分析 ProgressWheel : 自定义view ...
随机推荐
- GO语言list剖析
GO语言list剖析 本节内容 使用方法 list提供的方法 源码剖析 1. 使用方法 在GO语言的标准库中,提供了一个container包,这个包中提供了三种数据类型,就是heap,list和rin ...
- 超时 CS-8610 中性笔
超时 CS-8610 中性笔 最初觉得这款笔很简单,而且还认为有点丑,因为笔头比较短. 比较特别提这款中性笔比一般的中性笔要粗一点. 使用后才发现比其它的中性笔好用,因为笔杆粗,手感好,笔杆上并没有特 ...
- jslint报错太多的解决方式
当jslint 一个js的时候,有时候太多“错误”,导致报错:“Too many errors. (53% scanned).”而停止检查 js文件,此时我们还是想把整个js文件检查完毕的. 所以,看 ...
- angular track by $index
这个东西配合删除数组时会出现永远删除uoloadPicArr这个数组的最后一个一项 其用法是主要用在当ng-repeat循环时如果其内部的dom元素有id属性存在 可以避免页面出现相同的id 只是一 ...
- bzoj 3625(CF 438E)The Child and Binary Tree——多项式开方
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3625 http://codeforces.com/contest/438/problem/E ...
- 如何配置nagios监控SUN(富士通)MX000系列服务器的XSCF
配置环境说明 192.168.3.80-XSCF地址 192.168.2.80-solaris操作系统IP地址 (nagios客户端) 192.168.2.120-nagios服务器端 check_x ...
- Android实现智能提示的文本输入框AutoCompleteTextView
今天我们要讲一个十分简单的内容,就是一个安卓控件的使用,用法很简单,但是很常用的一个.这里我用两种不同的写法来处理.当然,无论用哪一种写法,效果都是一样的. 我们先来看效果图. 要实现这种效果十分简单 ...
- Android ScrollView 内部控件 layout_margin失效的解决方法
在<ScrollView> 的<LinearLayout >属性里面加入android:layout_gravity="top" <LinearLa ...
- JavaScript的流程控制语句
JS的核心ECMAScript规定的流程控制语句和其他的程序设计语言还是蛮相似的.我们选择一些实用的例子来看一下这些语句.顺序结构我们在这里就不再提到,直接说条件和循环以及其他语句.一.条件选择结构 ...
- springboot中单元测试
测试service: 测试api: