[英]What is the correct way to pass an Enum as an argument to a Fragment using Navigation Component safeargs
[英]How to pass a List as an argument to a Fragment using Navigation Component safeargs
該文檔討論了如何發送簡單的整數和字符串。 例如:
<argument
android:name="myIntArg"
android:defaultValue="255"
app:argType="integer" />
在原始片段中:
val action = OriginFragmentDirections.myAction(myInt)
findNavController().navigate(action)
在目標片段中:
val receivedInt = DestinationFragmentArgs.fromBundle(arguments).myIntArg
但是說而不是myIntArg
,我想發送一個整數列表( myIntListArg
)。 我該怎么做? 我會在我的論點中使用什么app:argType
?
您可以像這樣添加數組參數:
<argument
android:name="variableName"
app:argType="className[]"/>
請注意,“className”必須設置為“com.google.package.ClassName”。
這就是您可以傳遞整數列表的方式。
<argument
android:name="yourVariableName"
app:argType="integer[]"
app:nullable="false"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.