ListView和图像 [英] ListView and images

查看:161
本文介绍了ListView和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个问题的ListView +图像。
我得到的值从包含所有必要的相关信息的XML文件的列表中。


  1. 我需要建立一个列表视图。每一行应包含一个图标和标题。该图标是一个局部绘制(运蒙山应用程序)。

    我想实现的一个例子可以在这里找到: http://www.tutomobile.fr/wp-content/uploads/2010/07/listViewPerso_1.png

    我需要一个动态的方式将图片添加到ListView,XML文件内容可能改变。


  2. 是一样的previous但此时图像的服务器上承载,所以我需要从服务器上加载它们,然后在列表中显示出来。



解决方案

一个ListView项可以有它自己的自定义布局。当您创建适配器为ListView可以在布局ID的适配器构造通过。见SimpleAdapter和ArrayAdapter。你会 不得不延长一个适配器并实现getView()财产设置图像+文字。

下面是一个完整的示例code <一个href=\"http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012\">http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012.你可以重复使用它。

I have two problems with ListView+images. I get the values for the list from an xml file which contains all necessary infos.

  1. I need to set up a Listview. Every row should contain an icon and a title. The icon is a local drawable (shipped whith the app).

    An example what I want to achieve can be found here: http://www.tutomobile.fr/wp-content/uploads/2010/07/listViewPerso_1.png

    I need a dynamic way to add images to the ListView, the xml file contents may change.

  2. Is the same as the previous but this time the images are hosted on a server so I need to load them from the server and then display them in the list.

解决方案

A ListView item can have it's own custom layout. When you create your adapter for the ListView you can pass in the layout id to the Adapter constructor. See SimpleAdapter and ArrayAdapter. You will have to extend an Adapter and implement getView() to property set the image+text.

Here's a complete sample code http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012. You can reuse it.

这篇关于ListView和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆