当前位置: 移动技术网 > IT编程>移动开发>Android > Android编程实现加载等待ProgressDialog的方法

Android编程实现加载等待ProgressDialog的方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

皇金管家,朋克什么意思,金币网

本文实例讲述了android编程实现加载等待progressdialog的方法。分享给大家供大家参考,具体如下:

显示progressdialog的类:

import android.app.progressdialog;
import android.content.context;
import android.content.dialoginterface;
import android.content.dialoginterface.oncancellistener;
public class showprogressdialog {
  public static progressdialog wait;
  public static void show(context context,string msg,thread thread) {
    final thread th = thread;
    wait = new progressdialog(context);
    //设置风格为圆形
    wait.setprogressstyle(progressdialog.style_spinner);
    wait.settitle(null);
    wait.seticon(null);
    //设置提示信息
    wait.setmessage(msg);
    //设置是否可以通过返回键取消
    wait.setcancelable(true);
    wait.setindeterminate(false);
    //设置取消监听
    wait.setoncancellistener(new oncancellistener() {
      @override
      public void oncancel(dialoginterface dialog) {
        th.interrupt();
      }
    });
    wait.show();
  }
}

调用的时候显示progressdialog作为主线程,另起线程进行业务处理,等到业务处理完调用showprogressdialog.wait.dismiss();关闭progressdialog。处理完如需提示信息,直接在业务线程中是不行的,需要通过handler实现线程和activity的交互

希望本文所述对大家android程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网