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...
in Drawable folder of res in project directory, make xml file and name it as layerlist. xml and paste it below code as your requirement. you can also add your shape drawable instead of drawable in the <item/> tag in the example. and use this xml as a background of ImageView .
To do that, you don't want an array of Drawable's, just an array of resource identifiers, because 'setImageResource' takes those identifiers. How about this:
int[] myImageList = new int[]{R.drawable.thingOne, R.drawable.thingTwo}; // later... myImageView.setImageResource(myImageList[i]);
Or for a resizable version:
ArrayList<Integer> myImageList = new ArrayList<>(); myImageList.add(R.drawable.thingOne); // later... myImageView.setImageResource(myImageList.get(i));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With