Hoo
Hoo

Reputation: 1840

Pass mutableList through intent

I have a mutableList.

var newList: MutableList<String> = mutableListOf()

How to pass newList through intent?

I tried this but not working.

 mIntent.putParcelableArrayListExtra("mFilePath", ArrayList(newList))

Error

Type inference failed. Expected type mismatch: required: java.util.ArrayList! found: kotlin.collections.ArrayList /* = java.util.ArrayList */

Upvotes: 3

Views: 1155

Answers (3)

Hoo
Hoo

Reputation: 1840

Was able to fix it.

  mIntent.putStringArrayListExtra("mFilePath", ArrayList(newList))

Upvotes: 4

Black mamba
Black mamba

Reputation: 472

you can convert it on arraylist and pass as putParcelableArrayListExtra through intent

you can create separate model class and add that model class to your arraylist and make it Parcelize through this you can achieve this@Parcelize class model:Parcelable{ }

Upvotes: 0

Manikandan K
Manikandan K

Reputation: 921

You can use this way

intent.putParcelableArrayListExtra("NEW_LIST", ArrayList(newList))

Upvotes: 1

Related Questions