1

我在我的项目中使用单个活动结构,并且我想使用导航组件处理深度(应用程序)链接。一切都很好,但我无法处理数组查询参数。我想将complex_types作为字符串数组。

现有网址:

my.example.com/?guests=1&complex_types=hotel&complex_types=motel

nav_graph.xml:

     <fragment
        android:id="@+id/complexFragment"
        android:name="com.the.example.packagename.ComplexFragment"
        android:label="ComplexFragment">
        <argument
            android:name="guests"
            android:defaultValue="1"
            app:argType="integer" />
        <argument
            android:name="complexFilters"
            app:argType="???" />
        <deepLink
            android:id="@+id/deepLink_complex_fragment"
            app:uri="my.example.com/?guests={guests}&amp;complex_types={complexFilters}" />
    </fragment>

我不知道必须使用什么类型的 argType 而不是??? complexFilters参数中。

4

1 回答 1

2

在 android 编辑器中有一个用于数组的复选框,或者你 在此处输入图像描述

并且在 xml 导航图中将是这样的

   <argument
        android:name="images"
        android:defaultValue="@null"
        app:argType="string[]"
        app:nullable="true" />
于 2020-06-08T16:02:13.143 回答