国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android編程實現加載等待ProgressDialog的方法

2020-04-11 11:06:11
字體:
來源:轉載
供稿:網友

本文實例講述了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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柘城县| 贵州省| 正镶白旗| 弥渡县| 潜江市| 阿坝| 秭归县| 通渭县| 定远县| 垫江县| 泽州县| 固安县| 泰宁县| 鹰潭市| 尚志市| 松江区| 廊坊市| 津市市| 淮南市| 永年县| 广元市| 彭水| 灵川县| 肥西县| 奉新县| 于田县| 南陵县| 星子县| 拜城县| 华池县| 运城市| 响水县| 淮安市| 深州市| 昌都县| 通山县| 邻水| 革吉县| 贵南县| 仪征市| 湘潭市|