【转】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="@ ...
随机推荐
- C#发送邮件-C#教程
如何利用C#实现邮件发送功能?闲话不多说请看代码: public static void SendMail(MyEmail email){//发送验证邮箱邮件.//1.创建邮件MailMessage ...
- 转--DataTable 修改列名 删除列 调整列顺序
DataTable myDt =dt; //删除列 myDt.Columns.Remove("minArea"); myDt.Columns.Remove("maxAre ...
- css3遇到的一些属性
rgba 是由red.green.blue 三种颜色搭配出来的box-shadow 向元素添加阴影层,水平阴影位置,垂直阴影位置,后面是可选:模糊距离,阴影大小,颜色,是否是 ...
- Browser Link: Failed to deserialize JSON in Browser Link call
问题 VS2013中调试程序发现,在浏览器控制台输出如下截图代码:
- 完美解决 未能打开编辑器:Unmatched braces in the pattern.
Eclipse出现这个问题而不能查看源代码 原因就是语言包的问题 出现这个问题了 一定是安装了中文或者多国语言包 下面我就来交大家解决的办法 超简单的 第一步 配置自己Eclipse的启动参数 ecl ...
- 浏览器兼容问题----Firefox不兼容event的解决方法
一.event.srcElement:当前事件的源: 在IE下,event对象有srcElement属性,但是没有target属性;Firefox下,event对象有target属性,但是没有srcE ...
- 使用Eclipse把java文件打包成jar 含有第三方jar库的jar包
使用Eclipse把java文件打包成jar 含有第三方jar库的jar包 网上打包说用eclipse安装fat jar插件,但是貌似现在都不能用了,所以我只能按照eclipse自带的方法打包了. ...
- the c programming language 2-3
#include<stdio.h> #define MAXLINELEN 1000 int power(int base,int n) { ; ; ;i<n;i++) answer= ...
- 由C到C++的学习 ----Essential C++
一.array[] 与 vector<int> vector1 1 array[] <- 此中要填写数组的大小,而且array[]自己是不知道自己的大小的 2.1 vector< ...
- curl批处理从官方demo封装
官方demo // 创建一对cURL资源 $ch1 = curl_init(); $ch2 = curl_init(); // 设置URL和相应的选项 curl_setopt($ch1, CURLOP ...