Java Android ListView,带有来自特殊hashmap的图像

Java Android ListView,带有来自特殊hashmap的图像,java,android,listview,imageview,Java,Android,Listview,Imageview,我尝试处理一个hashmap来显示带有图像的listview。我搜索的答案如下:。但它不起作用 我的代码是: for (int i = 0; i < nodes.getLength(); i++) { Element e = (Element)nodes.item(i); Map<String, Object> datum = new HashMap<String, Object>(2); String img_url = getValue(e, "pic"); U

我尝试处理一个hashmap来显示带有图像的listview。我搜索的答案如下:。但它不起作用

我的代码是:

for (int i = 0; i < nodes.getLength(); i++) {
Element e = (Element)nodes.item(i);
Map<String, Object> datum = new HashMap<String, Object>(2);
String img_url = getValue(e, "pic");
URL url = null;
                        try {
                            url = new URL(img_url);
                        } catch (MalformedURLException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                        Bitmap bmp = null; 
                        try {
                            bmp=BitmapFactory.decodeStream(url.openConnection().getInputStream());
                        } catch (IOException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }

                        datum.put("imgurl", bmp);
                        datum.put("title", getValue(e, "title"));
                        datum.put("date", getValue(e, "description"));
                        datum.put("ex", "Autor: "+getValue(e, "creator")+" · Datum: "+getValue(e, "pubDate"));
                        datum.put("id", getValue(e, "id"));

                        data.add(datum);
                }       


final ListView lv = (ListView)findViewById(R.id.listView1);
ada = new SimpleAdapter(getApplicationContext(), data, R.layout.vlistimage, new String[] {"imgurl", "title", "date", "ex", "id"}, new int[] {R.id.list_image, android.R.id.text1, android.R.id.text2, R.id.text3}); 
lv.setAdapter(ada);
for(int i=0;i

谢谢你的提示/帮助

这是一个非常常见的问题,你可以用谷歌搜索这个例子。我可以肯定地告诉您,将图像存储在内存中是错误的,因为您可以从内存异常中获得


要了解如何使用图像和缓存,请访问

,这是一个非常常见的问题,您可以通过谷歌搜索示例。我可以肯定地告诉您,将图像存储在内存中是错误的,因为您可以从内存异常中获得


要了解如何使用图像和缓存,请访问

是的,在android中处理图像很困难,您需要在后台下载图像。对于主线程来说,处理您的请求太麻烦了。您可能肯定会离开内存OK,我尝试覆盖SimpleAdapter。关于这个方法,我还有一个问题:谢谢!是的,在android中处理图像是一件很难下载后台图像的事情。主线程处理您的请求太头疼了。您可能会离开MemoryOK,我试图覆盖SimpleReadApter。关于这个方法,我还有一个问题:谢谢!