【问题标题】:sometimes showDialog doesn't work有时 showDialog 不起作用
【发布时间】:2012-12-10 21:57:40
【问题描述】:

我有一个 fragmentActivity,它使用 startActivityForResult(intent, getCode) 来调用通过 ftp 发送一些文件的活动。

在方法onActivityResult(int requestCode, int resultCode, Intent data)中使用对话框。

对话框是这样调用的:

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();
}

一切正常,但我注意到当我非常快地显示和关闭对话框时(我可以更快,每秒一次或两次),在某些时候对话框不再显示,直到我关闭活动并启动它又...

这里发生了什么?我怎样才能真正确定对话框会显示?

谢谢!

【问题讨论】:

    标签: java android dialog


    【解决方案1】:

    活动为每个对话框调用一次 onCreateDialog().. 所以.. 我认为您应该使用 DialogInterface.OnShowListener 进行对话框视图小部件验证

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-10
      • 1970-01-01
      • 2015-03-04
      • 1970-01-01
      • 1970-01-01
      • 2013-04-22
      • 2021-04-12
      相关资源
      最近更新 更多