Issue
I am trying pass ArrayList data from one fragment to another fragment using safe args, here is the argument
<argument
android:name="upcomingEvents"
app:argType="com.x.Models.Event[]" />
but when I want to pass data using safe args, I have this error

it is said that
type mismatch.
required: Array<(out) Event!>
Found: ArrayList
how to convert ArrayList<Event> to Array<(out) Event!> ?
and also vice versa , how to convert Array<(out) Event!> to ArrayList<Event> ?
Solution
Kotlin has built in methods for both operations, namely, toTypedArray() and asList():
val upcomingEvents = currentUserData!!.upcomingEvents
val array = upcomingEvents.toTypedArray()
// On the other side
val array = ...
val list = array.asList()
Answered By - ianhanniballake
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.