How to set `null` as the default value for a nullable argument using SafeArgs?

試著忘記壹切 提交于 2020-05-12 11:31:25

问题


How should I pass in null as default value for a String argument such as this:

<argument
    android:name="profile_id"
    android:defaultValue="???"
    app:argType="string"
    app:nullable="true" />

If the argument is nullable there should be a way to pass in null right?


回答1:


Turns out the good old @null works

<argument
    android:name="profile_id"
    android:defaultValue="@null"
    app:argType="string"
    app:nullable="true" />


来源:https://stackoverflow.com/questions/53661394/how-to-set-null-as-the-default-value-for-a-nullable-argument-using-safeargs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!