Issue
I'm put ArrayList into bundle:
private val data: ArrayList<MyDay> = arrayListOf()
override fun getItemCount() = data.size
fun submitData(data: List<MyDay>) {
this.data.apply {
clear()
addAll(data)
}
notifyDataSetChanged()
}
override fun createFragment(position: Int): Fragment {
return if (position < data.size) {
DayWeatherFragment().apply {
arguments = Bundle().apply {
putSerializable(FIVE_DAYS_DATA, data[position])
}
}
} else Fragment()
}
but when i'm trying to get it in my fragment:
val args = arguments?.getSerializable(FIVE_DAYS_DATA)
args?.apply { }
I can't see fields in my array because it's type of Serializable
Solution
Problem solved. To get Array you just need to put which type of data you want to get:
val args = arguments?.getSerializable(FIVE_DAYS_DATA) as MyDay
Answered By - SoulReaver313
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.