androidx 导航:@NonNull 公共开放乐趣的参数太多 [英] androidx Navigation: Too many arguments for @NonNull public open fun
本文介绍了androidx 导航:@NonNull 公共开放乐趣的参数太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Android Studio 中使用导航编辑器来实现 Safe Args
.
I am using Navigation Editor in Android Studio to implement Safe Args
.
我接受一个片段中的参数为
I am accepting arguments in one fragment as
<fragment
android:id="@+id/gameWonFragment"
android:name="com.example.android.navigation.GameWonFragment"
android:label="@string/android_trivia"
tools:layout="@layout/fragment_game_won">
<action
android:id="@+id/action_gameWonFragment_to_gameFragment"
app:destination="@id/gameFragment"
app:popUpTo="@+id/titleFragment">
</action>
<argument
android:name="numQuestions"
app:argType="integer"
android:defaultValue="0" />
<argument
android:name="numCorrect"
app:argType="integer"
android:defaultValue="0" />
</fragment>
在我的 Fragment 中,我将参数发送为
And in my Fragment, I am sending arguments as
view.findNavController().navigate(GameFragmentDirections.actionGameFragmentToGameWonFragment(numQuestions, questionIndex))
但是,GameFragmentDirections.actionGameFragmentToGameWonFragment()
不想接受参数.我尝试了 Clean Project
和 Rebuild Project
.
But, GameFragmentDirections.actionGameFragmentToGameWonFragment()
doesn't want to accept arguments. I tried Clean Project
and Rebuild Project
.
这是投掷:
Too many arguments for @NonNull public open fun actionGameFragmentToGameWonFragment(): GameFragmentDirections.ActionGameFragmentToGameWonFragment defined in com.example.android.navigation.GameFragmentDirections
推荐答案
此问题已通过移除 android:defaultValue
标签解决.
This issue is fixed by removing the android:defaultValue
tag.
所以 -
<argument
android:name="numQuestions"
app:argType="integer"/>
<argument
android:name="numCorrect"
app:argType="integer"/>
然后在进行更改后Rebuild Project
.
这篇关于androidx 导航:@NonNull 公共开放乐趣的参数太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文