Load Image from server and diaplay in listview [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-23 06:41:09

问题


After parsing JSON array I'm getting image path How can I download that image and set it in list view.

 JSONObject iobject = aJson.getJSONObject(0);
 JSONObject imgObject =  iobject.getJSONObject("img_update");
 String img = imgObject.getString("0");

Here in string 'img' am getting image path How can I set it to a imageview in list what is simple and efficient solution for displaying those images in my android app as there will be hundreds of images.

following is my code in adapter class to set that image.There might be some error as its not working I read some tutorials related to this .

                if(image != null) {
                String img_path = "http://192.168.2.102/bootstrap/userapp_server/" +                   evnt.getEventImg();
                File imgFile = new  File(img_path);
                Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
                image.setImageBitmap(myBitmap);  
                }

回答1:


You can use universal image loader liabrary for loading image from server they provided good implementation for loading and caching image. Find it here



来源:https://stackoverflow.com/questions/27054657/load-image-from-server-and-diaplay-in-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!