Android DialogFragment的onCreateView中保存的实例束为空
在显示警告对话框之前,我正在保存一个键值对。但是,对话框的Android DialogFragment的onCreateView中保存的实例束为空,android,fragment,bundle,Android,Fragment,Bundle,在显示警告对话框之前,我正在保存一个键值对。但是,对话框的onCreateDialog()是用空绑定调用的。我需要做些额外的事情来将包传递给对话框吗 MyDialogFragment testFrag= new MyDialogFragment(); Bundle args = new Bundle(); args.putString("car-type", "Audi"); testFrag.setArguments(args); testFrag.show(getFragmentManage
onCreateDialog()
是用空绑定调用的。我需要做些额外的事情来将包传递给对话框吗
MyDialogFragment testFrag= new MyDialogFragment();
Bundle args = new Bundle();
args.putString("car-type", "Audi");
testFrag.setArguments(args);
testFrag.show(getFragmentManager(), "info");
您可以通过
DialogFragment.getArguments()
检索参数
savedInstanceState
仅在发生配置更改时使用。它被填入onSaveInstanceState(Bundle outState)
,然后被传递到onCreate()
和onCreateView()
中的新对话框fragment
。第一次创建片段或活动时,它是null
使用getArguments
检索setArguments
捆绑包
作为onCreateDialog
方法参数的savedInstanceState
捆绑包是在onSaveInstanceState
中填充的捆绑包
这两个完全无关