Android ProgressDialog进度条对话框的使用: 
转自:http://aina-hk55hk.iteye.com/blog/679134/

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical" android:layout_width="fill_parent"
  4. android:layout_height="fill_parent">
  5. <TextView android:layout_width="fill_parent"
  6. android:layout_height="wrap_content" android:text="@string/hello" />
  7. <Button android:text="圆形进度条" android:id="@+id/Button01"
  8. android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
  9. <Button android:text="长型进度条" android:id="@+id/Button02"
  10. android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
  11. </LinearLayout>
    1. package com.Aina.Android;
    2. import android.app.Activity;
    3. import android.app.ProgressDialog;
    4. import android.content.DialogInterface;
    5. import android.os.Bundle;
    6. import android.view.View;
    7. import android.view.View.OnClickListener;
    8. import android.widget.Button;
    9. public class Test_ProgressDialog extends Activity {
    10. /** Called when the activity is first created. */
    11. private ProgressDialog mpDialog;
    12. private Button btn1,btn2;
    13. private int mCount = 0;
    14. @Override
    15. public void onCreate(Bundle savedInstanceState) {
    16. super.onCreate(savedInstanceState);
    17. setContentView(R.layout.main);
    18. btn1 = (Button) this.findViewById(R.id.Button01);
    19. btn2 = (Button) this.findViewById(R.id.Button02);
    20. btn1.setOnClickListener(new OnClickListener(){
    21. @Override
    22. public void onClick(View v) {
    23. mpDialog = new ProgressDialog(Test_ProgressDialog.this);
    24. mpDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);//设置风格为圆形进度条
    25. mpDialog.setTitle("提示");//设置标题
    26. mpDialog.setIcon(R.drawable.icon);//设置图标
    27. mpDialog.setMessage("这是一个圆形进度条");
    28. mpDialog.setIndeterminate(false);//设置进度条是否为不明确
    29. mpDialog.setCancelable(true);//设置进度条是否可以按退回键取消
    30. mpDialog.setButton("确定", new DialogInterface.OnClickListener(){
    31. @Override
    32. public void onClick(DialogInterface dialog, int which) {
    33. dialog.cancel();
    34. }
    35. });
    36. mpDialog.show();
    37. }
    38. });
    39. btn2.setOnClickListener(new OnClickListener(){
    40. @Override
    41. public void onClick(View v) {
    42. mCount = 0;
    43. mpDialog = new ProgressDialog(Test_ProgressDialog.this);
    44. mpDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    45. mpDialog.setTitle("提示");
    46. mpDialog.setIcon(R.drawable.icon);
    47. mpDialog.setMessage("这是一个长型进度条");
    48. mpDialog.setMax(100);
    49. mpDialog.setProgress(0);
    50. mpDialog.setSecondaryProgress(50);
    51. mpDialog.setIndeterminate(false);
    52. mpDialog.setCancelable(true);
    53. mpDialog.setButton("取消", new DialogInterface.OnClickListener(){
    54. @Override
    55. public void onClick(DialogInterface dialog, int which) {
    56. dialog.cancel();
    57. }
    58. });
    59. new Thread(){
    60. public void run(){
    61. try{
    62. while(mCount<=100){
    63. mpDialog.setProgress(mCount++);
    64. Thread.sleep(100);
    65. }
    66. mpDialog.cancel();
    67. }catch(Exception ex){
    68. mpDialog.cancel();
    69. }
    70. }
    71. }.start();
    72. mpDialog.show();
    73. }
    74. });
    75. }
    76. }

【转】【Android】ProgressDialog进度条对话框的使用的更多相关文章

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

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

  2. android学习笔记20——ProgressDialog进度条对话框

    ProgressDialog==>进度条对话框 ProgressDialog本身就代表一个进度条对话框,程序只需要创建ProgressDialog实例,并将其显示出来就是一个进度条对话框:开发者 ...

  3. 【转】24. android dialog ——ProgressDialog 进度条对话框详解

    原文网址:http://blog.csdn.net/jamesliulyc/article/details/6375598 首先在onCreateDialog方法里创建一个ProgressDialog ...

  4. ProgressDialog进度条对话框

    (一) 1.效果图: 2.activity_main.xml <?xml version="1.0" encoding="utf-8"?> < ...

  5. Android开发 ---构建对话框Builder对象,消息提示框、列表对话框、单选提示框、多选提示框、日期/时间对话框、进度条对话框、自定义对话框、投影

    效果图: 1.activity_main.xml 描述: a.定义了一个消息提示框按钮 点击按钮弹出消息 b.定义了一个选择城市的输入框 点击按钮选择城市 c.定义了一个单选提示框按钮 点击按钮选择某 ...

  6. Android 进度条对话框ProgressDialog

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  7. 025 Android 带进度条的对话框(ProgressDialog)

    1.ProgressDialog介绍 ProgressDialog可以在当前界面弹出一个置顶于所有界面元素的对话框,同样具有屏蔽其他控件的交互能力,用于提示用户当前操作正在运行,让用户等待: 2.应用 ...

  8. Android Studio常见对话框(普通对话框、单选对话框、多选对话框、进度条对话框、消息对话框、自定义对话框)

    Android Studio常见对话框(普通对话框.单选对话框.多选对话框.进度条对话框.消息对话框.自定义对话框) 1.普通对话框 2.单选对话框 3.多选对话框 4.进度条对话框 5.消息对话框 ...

  9. ProgressWheelDialogUtil【ProgressWheel Material样式进度条对话框】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 简单封装网络请求时的加载对话框以及上传.下载文件的进度加载对话框. 效果图 代码分析 ProgressWheel : 自定义view ...

随机推荐

  1. GO语言list剖析

    GO语言list剖析 本节内容 使用方法 list提供的方法 源码剖析 1. 使用方法 在GO语言的标准库中,提供了一个container包,这个包中提供了三种数据类型,就是heap,list和rin ...

  2. 超时 CS-8610 中性笔

    超时 CS-8610 中性笔 最初觉得这款笔很简单,而且还认为有点丑,因为笔头比较短. 比较特别提这款中性笔比一般的中性笔要粗一点. 使用后才发现比其它的中性笔好用,因为笔杆粗,手感好,笔杆上并没有特 ...

  3. jslint报错太多的解决方式

    当jslint 一个js的时候,有时候太多“错误”,导致报错:“Too many errors. (53% scanned).”而停止检查 js文件,此时我们还是想把整个js文件检查完毕的. 所以,看 ...

  4. angular track by $index

    这个东西配合删除数组时会出现永远删除uoloadPicArr这个数组的最后一个一项 其用法是主要用在当ng-repeat循环时如果其内部的dom元素有id属性存在 可以避免页面出现相同的id  只是一 ...

  5. 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 ...

  6. 如何配置nagios监控SUN(富士通)MX000系列服务器的XSCF

    配置环境说明 192.168.3.80-XSCF地址 192.168.2.80-solaris操作系统IP地址 (nagios客户端) 192.168.2.120-nagios服务器端 check_x ...

  7. Android实现智能提示的文本输入框AutoCompleteTextView

    今天我们要讲一个十分简单的内容,就是一个安卓控件的使用,用法很简单,但是很常用的一个.这里我用两种不同的写法来处理.当然,无论用哪一种写法,效果都是一样的. 我们先来看效果图. 要实现这种效果十分简单 ...

  8. Android ScrollView 内部控件 layout_margin失效的解决方法

    在<ScrollView> 的<LinearLayout  >属性里面加入android:layout_gravity="top" <LinearLa ...

  9. JavaScript的流程控制语句

    JS的核心ECMAScript规定的流程控制语句和其他的程序设计语言还是蛮相似的.我们选择一些实用的例子来看一下这些语句.顺序结构我们在这里就不再提到,直接说条件和循环以及其他语句.一.条件选择结构  ...

  10. springboot中单元测试

    测试service: 测试api: