I have a data class
@Parcelize
data class PublicationPageModel(
@SerializedName("pageNumber")
val pageNumber: Int,
@SerializedName("content")
val content: String
): Parcelable
I already added items to the array like this:
private var publicationPageModel: ArrayList<PublicationPageModel> = arrayListOf()
publicationPageModel.add(PublicationPageModel(finalPageNumber, fileContent))
Now, I want to add additional item to the fileContent already in the model above ↑
Say add a string "hello" to each of the content in the model
E.g if I have:
- PageModel("1", "content1")
- pageModel("2", "content2")
Now I want to have:
- PageModel("1", "hello content1")
- PageModel("2", "hello content2")
How to do this please?
2
Answers
Since you want to add new value but only 1 String affected. Just append new value. Change the
fileContent
tovar
type.You could try with MessageFormat.
You could event put that "Hello {0}" in String resources and when you need it retrieve it from there.