在我的活动中,我在 onCreate() 中调用 MyDialog(自定义对话框)并在 Activity 中处理其 DismissListener 以查找其是否取消。如果它被取消,我完成活动,否则加载活动。在此加载期间,我想显示一个警报/进度对话框,让用户知道它正在加载,请稍候。但我看不到对话框。这就是我编码的方式:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ld = new AgreeDialog(this);
ld.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (ld.isCancelled)
MyActivity.this.finish();
else {
//ProgressDialog pd = CreateLoadingDialog();
//pd.show();
//Log.i(TAG, "Before Load Is PD showing - " + pd.isShowing()); // Shows true
/*
AlertDialog.Builder adb = new AlertDialog.Builder(StartUltimate.this);
adb.setTitle("Loading...");
adb.setCancelable(false);
AlertDialog ad = adb.create();
ad.show();
*/
MyActivity.this.showDialog(0);
LoadAfteAgree(); // This takes time sonetimes, so want a dialog while this is working
MyActivity.this.removeDialog(0);
//ad.dismiss();
// pd.dismiss();
//Log.i(TAG, "After Load Is PD showing - " + ad.isShowing()); // Shows false
}
}
});
@Override
protected Dialog onCreateDialog(int id) {
switch(id) {
case 0:
loadingDlg = new ProgressDialog(this);
loadingDlg.setMessage("Loading...");
loadingDlg.setCancelable(false);
loadingDlg.setIcon(R.drawable.icon);
return loadingDlg;
}
return null;
}
为什么我无法以任何方式看到任何对话框?我也尝试在 LoadAfterAgree() 中调用它们,但也没有成功,结果相同。
非常感谢任何帮助。
谢谢