【发布时间】:2021-10-02 12:41:44
【问题描述】:
我正在使用带有安全参数的 android 导航组件。 我设置参数可以为空,默认值也为空。
问题是当我想传递任何值时会显示错误:
required: no arguments
found: Character
reason: actual and formal argument lists differ in length
我的片段 XML 代码:
<fragment
android:id="@+id/bookListFragment"
android:name="com.example.bookstory.UI.Fragments.BookListFragment"
android:label="fragment_book_list"
tools:layout="@layout/fragment_book_list">
<argument
android:name="character"
app:argType="com.example.bookstory.DAO.Character"
app:nullable="true"
android:defaultValue="@null" />
</fragment>
我的行动:
<action
android:id="@+id/action_bookDescriptionFragment_to_bookListFragment"
app:destination="@id/bookListFragment"
app:popUpTo="@id/bookListFragment"
app:popUpToInclusive="true" />
我不明白问题出在哪里 - 当我删除默认值时就可以了。
【问题讨论】:
-
你如何传递值?..你没有包括那个
-
@Zain ``` ClassNameDirections.ActionName action = ClassNameDirections.actionName(character); Navigation.findNavController(v).navigate(action); ```
标签: android navigation android-safe-args