【转】【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 ...
随机推荐
- 图m的着色问题(搜索)
图的m着色问题 [问题描述] 给定无向连通图G和m种不同的颜色.用这些颜色为图G的各顶点着色,每个顶点着一种颜色.如果有一种着色法使G中每条边的2个顶点着不同颜色,则称这个图是m可着色的 ...
- shell while的用法
1. #!/bin/shint=1while (( "$int < 10" ))doecho "$int"let "int++"don ...
- vbs查看系统开关机时间
如何获取XP系统的开机时间? 下面给出两种代码,保存到扩展名为vbs的文件中.具体哪个请根据自己需求决定. 一:根据系统日志,查看开机时间和关机时间,---- 使用弹出对话框的形式 Set WMI = ...
- BZOJ1116:[POI2008]CLO
浅谈并查集:https://www.cnblogs.com/AKMer/p/10360090.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php? ...
- Monkey测试与MonkeyRunnner测试的区别
1.Monkey测试 == 压力测试: MonkeyRunner == 自动化测试 2.Monkey工具直接运行在设备或模拟器的adb shell中,生成用户或系统的伪随机事件 3.MonkeyRu ...
- python 修改文件内容
python 修改文件内容 一.修改原文件方式 1 def alter(file,old_str,new_str): 2 """ 3 替换文件中的字符串 4 :param ...
- height clientHeight scrollHeight offsetHeight的大致区别
这主要是针对火狐浏览器来讲的: height:就是div的高度,就是style中设置的高度:在chrome中clientHeight是包含padding的,offsetHeight和clientHei ...
- ARM模式下创建Express Route
在Azure的ARM模式下,创建Express Route的命令和ASM模式下是有一些区别的. 本文将介绍在ARM模式下,如果创建Express Route的Circuit. 1. 查看支持的Serv ...
- 【转】LTE基本架构
这篇文章主要介绍LTE的最基础的架构,包括LTE网络的构成,每一个网络实体的作用以及LTE网络协议栈,最后还包括对一个LTE数据流的模型的说明. LTE网络参考模型 这是一张非常有名的LTE架构图,从 ...
- 杂项:Grunt
ylbtech-杂项:Grunt GRUNTJavaScript 世界的构建工具 1. 返回顶部 1. 为何要用构建工具? 一句话:自动化.对于需要反复重复的任务,例如压缩(minification) ...