I am using the Safe Args plugin with the new Navigation components for my Android project. Now I have an argument that is an array list of parcelables, is there a way to use this with the Safe Args Plugin?
Something like app:argType=ParcelableArray
. This should be possible since there are bundle methods like putParcelableArrayList()
.
Safe Args is strongly recommended for navigating and passing data, because it ensures type-safety. In some cases, for example if you are not using Gradle, you can't use the Safe Args plugin. In these cases, you can use Bundles to directly pass data. You must also apply one of two available plugins.
Navigation SafeArgs Navigation Safe Args has upgraded the Android Gradle Plugin dependency to rely on 7.0. 4 , dropping compatibility for AGP versions before 7.0 . Added support for the namespace build. gradle attribute to be used instead of applicationId.
Yes, since version 1.0.0-alpha08 you can now pass arrays of parcelable objects like this:
<argument android:name="users" app:argType="com.navigation.test.User[]"/>
For passing arrays of primitive types use for e.g. app:argType="integer[]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With