android : ProgressDialog 進度條的快捷使用

private ProgressDialog myProgressDialog = null;//進度條

//顯示進度提示

public void showProgress(String title, String msg) {

try {

if (myProgressDialog != null) {

myProgressDialog.cancel();

}

myProgressDialog = ProgressDialog.show(this, title, msg);

myProgressDialog.setCancelable(false);

} catch (Exception e) {

} finally {

}

}

  

//取消進度提示

public void cancelProgress(){

try {

if (myProgressDialog!=null) {

myProgressDialog.dismiss();

myProgressDialog.cancel();

}

} catch (Exception e) {

} finally {

}

}

 

發佈留言