【问题标题】:Show() Method in DialogFragment not working in androidDialogFragment中的Show()方法在android中不起作用
【发布时间】:2015-04-10 23:55:17
【问题描述】:

我正在从 DialogFragment 内部调用 DialogFragment。此类中的 Show() 方法仅在特定情况下工作。代码如下:

//Not Working
 DialogBoxFragment dialog = new DialogBoxFragment();
 Bundle args = new Bundle();
 args.putString("selectedLine", "test");
 dialog.setArguments(args);
 android.app.FragmentManager fm = getActivity().getFragmentManager();
 dialog.show(fm,"Dialog");

如果我评论一些行,那么它会起作用:

 DialogBoxFragment dialog = new DialogBoxFragment();
// Bundle args = new Bundle();
// args.putString("selectedLine", "test");
// dialog.setArguments(args);
 android.app.FragmentManager fm = getActivity().getFragmentManager();
 dialog.show(fm,"Dialog");

在 DialogFragmentManager 类中我们有:

private void DeletePhoneNumber(){

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
    alertDialogBuilder.setTitle("SmartCall");
    alertDialogBuilder.setMessage(**getArguments().getString("selectedLine")**);
    alertDialog = alertDialogBuilder.create();
    alertDialog.show();

}

有人能解释一下原因吗?

提前非常感谢您。 莱昂纳多

【问题讨论】:

  • 您能否发布与DialogBoxFragmentselectedLine 参数所做的操作相关的代码?
  • 是否调用了DialogBoxFragment中的onCreateDialog?
  • 带有注释行的代码是的,但是如果我在 Show() 方法之前放置任何代码,它似乎没有被调用。

标签: android dialog show dialogfragment


【解决方案1】:

我已经解决了这个问题。 问题是 putString() 方法,我发送了错误的参数,但没有引发错误消息。

谢谢你帮助我。 莱昂纳多

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-20
    • 1970-01-01
    • 2016-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-19
    相关资源
    最近更新 更多