原文网址: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的更多相关文章

  1. 【转】Android ProgressDialog的使用

    原文网址:http://blog.csdn.net/sjf0115/article/details/7255280 版权声明:本文为博主原创文章,未经博主允许不得转载. <1>简介 Pro ...

  2. Android ProgressDialog 加载进度

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...

  3. android progressdialog 对话框试用实例

    ProgressDialog 跟AlertDialog用法差不多,不同的是:ProgressDialog 显示的是一种"加载中"的效果,android 中 ProgressDial ...

  4. android ProgressDialog 正在载...Loading...

    final ProgressDialog pd = new ProgressDialog(mContext); pd.setMessage("正在加载..."); pd.show( ...

  5. Android——ProgressDialog 进度条对话框

    public class ProgressDialogActivity extends Activity {    private Button btn_large_pd, btn_horizonta ...

  6. Android ProgressDialog 简单实用

    ProgressDialog progressDialog; @SuppressLint("HandlerLeak") Handler handler1 = new Handler ...

  7. android:ProgressDialog控件

    ProgressDialog 和 AlertDialog 有点类似,都可以在界面上弹出一个对话框,都能够屏蔽 掉其他控件的交互能力.不同的是,ProgressDialog 会在对话框中显示一个进度条, ...

  8. 自定义android ProgressDialog

    Android系统自己提供的UI的都是比较难看的,开发中经常用到自定义对话框,下面分享个最近项目中使用的加载框.   下面是源代码,主要的原理就是准备几个图片,然后循环播放. MainActivity ...

  9. Android学习笔记_81_Android ProgressDialog ProgressBar 各种效果

    1,弹出Dialog 屏幕不变暗. 创建一个样式就OK了:在styles.xml文件里添加样式: 1, <style name="dialog" parent="@ ...

随机推荐

  1. PHP+jQuery+Ajax实现用户登录与退…

    用户登录与退出功能应用在很多地方,而在有些项目中,我们需要使用Ajax方式进行登录,登录成功后只刷新页面局部,从而提升了用户体验度.本文将使用PHP和jQuery来实现登录和退出功能. 查看演示DEM ...

  2. C# 分页

    #region 分页 /// <summary> /// 分页 /// </summary> /// <param name="page">当前 ...

  3. XML的基本操作

    所有 XML 文档中的文本均会被解析器解析.只有 CDATA 区段(CDATA section)中的文本会被解析器忽略.CDATA 部分中的所有内容都会被解析器忽略.CDATA 部分由 "& ...

  4. webrtc学习———记录二:canvas学习

    参考资料: http://bucephalus.org/text/CanvasHandbook/CanvasHandbook.html#getcontext2d https://developer.m ...

  5. CentOS PHP-5.4.8 编译安装之初体验

    1. 下载5.4.8 版本 [root@Test data] wget http://museum.php.net/php5/php-5.4.8.tar.gz 2. 解压 [root@Test php ...

  6. Reporting Services 2: 参数化报表

    http://www.cnblogs.com/waxdoll/archive/2006/07/16/452467.html

  7. C# 执行批处理文件(*.bat)的方法代码

    代码如下: static void Main(string[] args){    Process proc = null;    try    {                        st ...

  8. CSS3 文本装饰

    浏览器对CSS3文本特性的支持情况,如下表所示: 浏览器 text-shadow text-overflow word-wrap hyphens Opera 9.5+ 9+.带前缀-o- 10.5+ ...

  9. 注解 @RequestMapping

    通过RequestMapping注解可以定义不同的处理器映射规则. 1.URL路径映射 @RequestMapping(value="/item")或@RequestMapping ...

  10. php的各种配置

    问题:1.如果去掉URL_MODEL=1时的index.php第一步:把Apache配置文件中的LoadModule rewrite_module modules/mod_rewrite.so 取消注 ...