1.效果图

进度条ProgressDialog

 

 public void click(View view) {
        final ProgressDialog pdDialog = new ProgressDialog(this);
        //设置标题
        pdDialog.setTitle("");
        //设置图标
        pdDialog.setIcon(R.mipmap.ic_launcher);
        //设置内容
        pdDialog.setMessage("数据加载中……");
        //返回键不能取消
        pdDialog.setCancelable(false);
        //设置进度条样式
        pdDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

        pdDialog.setMax(100);

        pdDialog.show();

        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    for (int i = 1; i < 150; i++) {
                        Thread.sleep(100);
                        pdDialog.setProgress(i);
                    }
                    pdDialog.dismiss();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }).start();

    }

 

相关文章:

  • 2021-10-17
  • 2021-10-05
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2021-04-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-18
  • 2021-10-25
  • 2022-12-23
  • 2021-11-11
  • 2021-11-30
  • 2022-12-23
  • 2022-02-16
相关资源
相似解决方案