简体   繁体   English

如何从 ImageView 列表中动态获取 imageview 并将 imageview 放置到 Z6C666B7F9E6BE3A848F2F 变量中

[英]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;如果我有一个充满图像视图的数组/列表- 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我在其中动态添加了一些图片/图标/图像,并且我有一个来自 imageview 类型的变量,称为 IV 和长度之间的数字

0 to the length of the list-1, 0 到 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?如何从列表/数组中获取 imageview 并将其设置为 IV,这是我们的变量 imageview 类型?

this is what I tried: IV=(iv.get(num));这就是我尝试过的: IV=(iv.get(num)); but nothing seems to happen as in the image in our variable imageview doesn't change但似乎什么都没有发生,因为我们的变量 imageview 中的图像没有改变

doing this all dynamically using java, no xml.使用 java 动态执行这一切,没有 xml。

You can use this.你可以使用这个。 Make sure to check for null.确保检查 null。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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