如何使用导航架构组件safeargs将参数传递给对话框片段?下面是我当前的实现
开始片段
val navController = findNavController()
val action =
QuestionListFragmentDirections.actionQuestionListFragmentToCustomDialogFragment(args.templateFlag)
navController.navigate(
action
)
目标片段
args.templateFlage //supposed to return a boolean value
//but throws java.lang.IllegalStateException: Fragment QuestionTypeDialogFragment{e8be5e1}
(47b305ea-35b2-49e0-b378-d31a08ba9a41) QuestionTypeDialogFragment} has null arguments
例如,您必须在xml导航声明中添加默认值:
<argument
android:name="ArgName"
android:defaultValue="@null"
app:argType="boolean"
app:nullable="true" />