【转】Android ProgressDialog的使用2
原文网址:http://www.cnblogs.com/hnrainll/archive/2012/03/28/2420908.html
<?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的使用2的更多相关文章
- 【转】Android ProgressDialog的使用
原文网址:http://blog.csdn.net/sjf0115/article/details/7255280 版权声明:本文为博主原创文章,未经博主允许不得转载. <1>简介 Pro ...
- Android ProgressDialog 加载进度
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...
- android progressdialog 对话框试用实例
ProgressDialog 跟AlertDialog用法差不多,不同的是:ProgressDialog 显示的是一种"加载中"的效果,android 中 ProgressDial ...
- android ProgressDialog 正在载...Loading...
final ProgressDialog pd = new ProgressDialog(mContext); pd.setMessage("正在加载..."); pd.show( ...
- Android——ProgressDialog 进度条对话框
public class ProgressDialogActivity extends Activity { private Button btn_large_pd, btn_horizonta ...
- Android ProgressDialog 简单实用
ProgressDialog progressDialog; @SuppressLint("HandlerLeak") Handler handler1 = new Handler ...
- android:ProgressDialog控件
ProgressDialog 和 AlertDialog 有点类似,都可以在界面上弹出一个对话框,都能够屏蔽 掉其他控件的交互能力.不同的是,ProgressDialog 会在对话框中显示一个进度条, ...
- 自定义android ProgressDialog
Android系统自己提供的UI的都是比较难看的,开发中经常用到自定义对话框,下面分享个最近项目中使用的加载框. 下面是源代码,主要的原理就是准备几个图片,然后循环播放. MainActivity ...
- Android学习笔记_81_Android ProgressDialog ProgressBar 各种效果
1,弹出Dialog 屏幕不变暗. 创建一个样式就OK了:在styles.xml文件里添加样式: 1, <style name="dialog" parent="@ ...
随机推荐
- 一个玩具程序——测试密码强度(pure C)
替人写的C语言作业… 介绍: 程序名称:密码强度检测程序 注释风格:doxygen 测试环境:linux3.6, gcc4.7window7, vs2012 已知问题:1. 算法与参考链接不一致,结果 ...
- mysql-distinct去重、mysql-group …
一.MYSQL-distinct用法 在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记 ...
- JS1-属性操作
属性操作语法 读操作:获取.找到 元素.属性名 写操作:“添加”.替换.修改 元素.属性名 = 新的值 元素.innerHTML => 读取元素里面所有的html代码 元素.innerHTML ...
- [转]eclipse github 提交代码
1 git add2 git commit3 git pull (会产生冲突) 分成自动合并和手动合并4 处理冲突的文件 5 git push 本次commit 我用的是Eclipse的插件EGit ...
- 浅谈C#关于AOP编程的学习总结
难得在这样一个节日里给写出一篇博客,却没有佳人相约,没办法,这就是一个程(dan)序(shen)猿(gou)的真实生活情景,每天除了coding还是coding.唉..污染各位看官的眼了.好吧,进入正 ...
- ipad屏幕旋转后的代理
- (void)statusBarOrientationChange:(NSNotification *)notification { UIInterfaceOrientation o ...
- Objective-C发展历史
Objective-C发展历史 苹果图标由来: 被咬了一口苹果的LOGO是为了纪念计算机科学的创始人阿兰· 麦席森· 图灵.当年图灵由于身为同性恋者,被强行 "治疗",在被迫注射大 ...
- 关于for循环中的闭包问题
还是昨天的那个简单的小项目,已经花了一天的时间了 - - .从&&的用法,到CSStext,到今天马上要谈的闭包(closure),通过一个小东西,真真发现了自己的各方面不足.昨天发完 ...
- Codevs 2549 自然数和分解
2549 自然数和分解 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 白银 Silver 传送门 题目描述 Description 把自然数N分解为若干个自然数之和,输出方案数. 输 ...
- 输出不大于N的素数的个数
输出不大于N的素数的个数 Sieve of Eratosthenes 方法 素数的性质: 非素数可以分解为素数乘积. 证明 (1)n = 2 成立,n = 3 成立: (2)若 n = k 时成立, ...