简体   繁体   中英

How to dynamically take a imageview from an ImageView List and place that imageview to an imageview variable

If I have an array/list full of imageviews- List<ImageView> iv; where I dynamically add a few pics/icons/images, and I have a variable from type imageview called IV and a number between the lengths of

0 to the length of the list-1,

how can I take the imageview from the list/array and set it to IV which is our variable which is imageview type?

this is what I tried: IV=(iv.get(num)); but nothing seems to happen as in the image in our variable imageview doesn't change

doing this all dynamically using java, no xml.

You can use this. Make sure to check for null.

IV.setImageDrawable(iv.get(num).getDrawable());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM