【发布时间】: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();
}
有人能解释一下原因吗?
提前非常感谢您。 莱昂纳多
【问题讨论】:
-
您能否发布与
DialogBoxFragment对selectedLine参数所做的操作相关的代码? -
是否调用了DialogBoxFragment中的onCreateDialog?
-
带有注释行的代码是的,但是如果我在 Show() 方法之前放置任何代码,它似乎没有被调用。
标签: android dialog show dialogfragment