Passing images from integer-array

I want to add some images to RecycleView, for this I created an array like below,

@drawable/plane/item> @drawable/auto @drawable/tools @drawable/computer

After that I’m trying to pass these Int image values to a variable for RecycleView.

var main_menu_images = resources.getIntArray(R.array.main_menu_category_image)

But the problem is, when I check from debug console, “main_menu_images”’ all array member’s value is 0.

How can I solve this?

Regards.

It is not clear what the resource is that defines your array. But it may not be an IntArray

I solved with obtainTypedArray method. Thanks for the answer anyway.

1 Like