我有一个 fragmentActivity,它使用 startActivityForResult(intent, getCode) 来调用通过 ftp 发送一些文件的 Activity 。
在方法 onActivityResult(int requestCode, int resultCode, Intent data) 中使用对话框<显示操作的结果(失败、成功、没有互联网等...)/strong>.
对话框是这样调用的:
Bundle bundle = new Bundle();
bundle.putString(LLAVE_TITULO, alertTitulo);
bundle.putString(LLAVE_MENSAJE, alertMensaje);
showDialog(DIALOG_RESPUESTA, bundle);
onCreateDialog 方法是基本的
@Override
protected Dialog onCreateDialog(int id, Bundle bundle)
{
Builder mAlertDialog = new AlertDialog.Builder(this);
mAlertDialog.setTitle(bundle.getString(LLAVE_TITULO));
mAlertDialog.setMessage(bundle.getString(LLAVE_MENSAJE));
mAlertDialog.setPositiveButton("Aceptar",null);
return mAlertDialog.create();
}
一切正常,但我注意到当我非常快地显示和关闭对话框时(我可以越快,每秒一次或两次)在某些时候对话框不再显示,直到我关闭 Activity 并启动它再次……
这里发生了什么?我如何才能真正确定对话框会显示?
谢谢!
最佳答案
Activity 为每个对话框调用一次 onCreateDialog() .. 所以..我认为你应该使用 DialogInterface.OnShowListener 进行对话框 View 小部件验证
关于java - 有时 showDialog 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13802139/