且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何刷新listview中的图像列表图像?

更新时间:2023-12-05 16:10:16

你做了以下错误:



你为每个循环创建列表的新实例。您将一个图像添加到列表并将其分配给列表。你为每个项目做。因此,最终结果是您的图像列表包含一个图像,并且您的列表将该列表作为图像源。



您需要做的是在循环外创建图像列表。将图像添加到循环中的列表中,并在循环完成后将图像列表分配到列表中。



询问是否有不清楚的地方。祝你好运。
You're doing the following wrong:

You create new instance of the list for each loop. You add one image to the list and assign it to the list. You do it for each item. So, final result is that your imagelist contains one image and your list has that list as image source.

What you need to do is create image list outside of the loop. Add images to the list in the loop and once the loop finishes assign the image list to your list.

Ask if something is not clear. Good luck.