Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1394954
  • 博文数量: 188
  • 博客积分: 1784
  • 博客等级: 上尉
  • 技术积分: 2772
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-05 22:20
个人简介

发上等愿,结中等缘,享下等福;择高处立,就平处坐,向宽处行。

文章分类

全部博文(188)

文章存档

2020年(12)

2019年(11)

2018年(4)

2017年(3)

2016年(11)

2015年(22)

2014年(19)

2013年(25)

2012年(32)

2011年(49)

分类: 嵌入式

2012-04-19 21:43:42


 

点击(此处)折叠或打开

  1. <Button android:id="@+id/button1" android:text="圆形进度条"
  2.   android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
  3.  <Button android:id="@+id/button2" android:text="长方形进度条"
  4.   android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>



  5. private Button xhButton1, xhButton2;
  6.  private int xh_count;
  7.  ProgressDialog xh_pDialog;

  8.  @Override
  9.  public void onCreate(Bundle savedInstanceState) {
  10.   super.onCreate(savedInstanceState);
  11.   setContentView(R.layout.main);
  12.   xhButton1 = (Button) findViewById(R.id.button1);
  13.   xhButton2 = (Button) findViewById(R.id.button2);

  14.   xhButton1.setOnClickListener(new OnClickListener() {

  15.    @Override
  16.    public void onClick(View arg0) {
  17.     // TODO Auto-generated method stub

  18.     xh_pDialog = new ProgressDialog(TabWidgetActivity.this);
  19.     xh_pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); //圆形进度条

  20.     xh_pDialog.setTitle("提示");
  21.     xh_pDialog.setMessage("这是一条提示信息");
  22.     xh_pDialog.setIcon(R.drawable.icon);
  23.     xh_pDialog.setIndeterminate(false);
  24.     xh_pDialog.setCancelable(false);
  25.     xh_pDialog.setButton("确定", new OnDialogClickListener());
  26.     xh_pDialog.show();

  27.    }
  28.   });

  29.   xhButton2.setOnClickListener(new OnClickListener() {

  30.    @Override
  31.    public void onClick(View arg0) {
  32.     // TODO Auto-generated method stub

  33.     xh_pDialog = new ProgressDialog(TabWidgetActivity.this);
  34.     xh_pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);//长方形进度条

  35.     xh_pDialog.setTitle("提示");
  36.     xh_pDialog.setMessage("这是一条提示消息");
  37.     xh_pDialog.setIcon(R.drawable.icon);
  38.     xh_pDialog.setCancelable(false);
  39.     xh_pDialog.setProgress(100);
  40.     xh_pDialog.setButton("确定", new OnDialogClickListener());
  41.     xh_pDialog.show();
  42.     
  43.     new Thread() {
  44.      public void run() {
  45.       xh_count=0;
  46.       try {
  47.        while (xh_count <= 100) {
  48.         xh_pDialog.setProgress(xh_count++);
  49.         Thread.sleep(100);
  50.        }
  51.        xh_pDialog.cancel();
  52.       } catch (InterruptedException e) {
  53.        // TODO Auto-generated catch block

  54.        xh_pDialog.cancel();
  55.       }
  56.      }
  57.     }.start();
  58.    }
  59.   });

  60.  }

  61.  class OnDialogClickListener implements DialogInterface.OnClickListener {

  62.   @Override
  63.   public void onClick(DialogInterface dialog, int arg1) {
  64.    // TODO Auto-generated method stub

  65.    dialog.cancel();
  66.   }

  67.  }


 

阅读(2592) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~