How can I make an array that handles some of my images so that I can use it like this?:
ImageView.setImageResource(image[1]);
I hope I explained well...
How can I make an array that handles some of my images so that I can use it like this?:
ImageView.setImageResource(image[1]);
I hope I explained well...
Kotlin code: initialize below class:
private var drawables: Array<Drawable>
initialize drawables in 1 line:
drawables = arrayOf(
model.getDrawable(R.drawable.welcome_1),
model.getDrawable(R.drawable.welcome_2),
model.getDrawable(R.drawable.welcome_3)
)
my model.getDrawable() is
fun getDrawable(id: Int): Drawable {
return ResourcesCompat.getDrawable(context.resources, id, context.theme)!!
}
set drawable to imageView
holder.imageView.setImageDrawable(drawables[position])