Downloads images from URL and display it in a GridView

I have a URL where some images are exists. I want to retrieve all the images from that URL and display these images in the GridView. Now when I click any of thumb preview like in grid view then it should enlarge or load to full screen.

putting the snap shots for better understandingDownloads images from URL and display it in a GridView

-------------Problems Reply------------

First figure out a way of how you are going to download all the images from a single link, which I believe is somewhat difficult.

Then put all the link locations into a string array. now use the below code to download the images.

public Drawable LoadImage(String url) {

Drawable d;
try {
InputStream is = (InputStream) new URL(url).getContent();
d = Drawable.createFromStream(is, "src name");
return d;
} catch (NullPointerException e) {
d = getResources().getDrawable(R.drawable.icon);
return d;
} catch (Exception e) {
d = getResources().getDrawable(R.drawable.icon);
return d;

Get the length of the string array in which you have stored the link locations. And inside of a for loop try executing the above code. This will return an drawable object which you can convert into either resources or Bitmap and add it to the GridView.

You can try the following code. Lazy loading the image is one good solution to load the images, you can try the lazy loading from the following link: Android - How do I do a lazy load of images in ListView . In this they have used a ListView in the layout so the images and the corresponding text are shown as list items, you can change that ListView to a GridView something like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:text="Clear Cache"/>

I think this will solve the issue.

Category:android Views:0 Time:2011-06-13

Related post

  • Windows batch file file download from a URL 2011-01-06

    I am trying to download a file from a website (ex. using a Windows batch file. I am getting an error code when I write the function below: xcopy /E /Y "" The batch file doesn't seem to lik

  • downloaded image from url is not showing in view 2011-09-16

    i want to ask that i am downloading images from url means i had url in string array and on button click i move to next url and downloaded image from server. it runs perfectly on samsung galaxy s2 mobile and image downloading and displaying in view bu

  • Downloading pdf from server and displaying it 2012-01-30

    I'm trying to Downloading pdf from server and displaying it as it is. I tried the following code snippet but it's giving me error as shown below. I'm not able to understand why it's giving No Activity found to handle Intent exception. I'm new to andr

  • Do you know free Download slideshow animation URL Using flash? 2009-03-25

    Duplicate of Do you know free Download slideshow animation URL Using flash ? --------------Solutions------------- you tag says jq

  • Maven: downloading files from url 2010-04-30

    Can I download some files from http while maven lifecycle? any plugin? --------------Solutions------------- If the file is a Maven dependency, you could use the Maven Dependency Plugin which has a get goal. For any file, you could use the Antrun plug

  • Get http file size, download location, and URL in a label 2010-09-18

    I am using this to download a file and get % info and completed info. I want to know how to get the size of the file being downloaded and the URL remote address and the local address where the file is being saved to. private void Form1_Load_1(object

  • Problem with downloading image from URL 2011-04-28

    I use such code for downloading image from URL: public static Bitmap downloadImage(String url) { Bitmap bitmap = null; InputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new URL(url).openStream(), IO_BUFFER_SIZ

  • Structuring a URL to display all results for scraping data 2011-07-24

    I am a GIS student working on a project focused on mapping unstructured data, in which I wrote a php script to scrape the following page that displays search results for US GIS job postings, to export to xml, geocode and map.

  • Download file from URL to the file system with PhoneGap 2011-10-04

    How can I download a file from URL to the file system with PhoneGap? I see there is a plugin for this (, but it's only for Android. Are there any cross-pla

  • I'm looking for a Sharepoint Webpart that can query a list for an RSS feed URL, then display it 2011-11-23

    Basically what I have a List that will be maintained by the user that has a field that contains a link to an RSS feed. I tried using the OOTB RSS and it's great, but you have to specify the feed URL and I need that to be based on user selection. For

  • Use DownloadManager to download from an URL accessible through a DefaultHttpClient 2011-11-28

    In my Android app I have to download files from URLs. I use the Android DownloadManager but the URLs are accessible only through a DefaultHttpClient. Infact these URLs are the result of several POST requests. I mean: I'm allowed to download the files

  • Display selected row of Gridview data to next page in another Gridview? 2010-01-02

    How can i Display selected row of Gridview data to next page in another Gridview? For example, In listing page i want to select perticular row and take that data to another page and display over there. I have two grid view one in 1st page and next on

  • Display dynamic data using GridView/DataList 2010-11-16

    I need to build a form that shows data is the following format: M(1 Nov), T(4 Nov), S(7 Nov) etc user 1 yes/no yes/no yes/no yes/no user 2 yes/no yes/no yes/no yes/no The yes/no will be represented by a check box and there will be Monday, Thursday an

  • Best way to display data in a gridview in C# 2011-06-07

    I have data of the format Filename Status abc.txt Found xyz.txt Not Found I need to display it on a gridview. How do I hold these values in? Should I use a multidimensional array or other collections? Which one would be best suited? --------------Sol

  • How to Use MediaStore to display all images in GridView 2011-12-30

    I need a little help in trying to figure out a problem that I am having. I have an application that will query all the images on the phone and display them in a GridView. I was able to do this and populate the list. The problem is when I am accessing

  • Web aaccess issues. URL just downloads source file rather than displaying in browser 2011-12-01

    I've stumbled across something I have never seen before. I have just set up a new site but whenever I go to any of the URL's on the site browsers just try to download the source file rather than displaying the page. I have tried this cross browser. h

  • android - download the image from url not displaying correctly 2011-12-29

    In my app, when you click on the button then I am downloading the images from the url's. It displaying the images some time correctly but some time it display empty. *problem is some times bitmap object(i.e, "result" in code ) return null.*please can

  • Download xml from url, parse it and display on page using phonegap on WP7 2012-01-15

    Can some one please help me with a sample code (phonegap on WP7) that would fetch a xml from given url, parse the xml and show contents in a list. I googled a lot but could not find a working solution Thx. --------------Solutions------------- Since p

  • django / python get image from url and display on site 2010-03-22

    Given a url to an image is there a way in Django/Python to pull this image in and then display it on my site (resized if possible) Thanks --------------Solutions------------- If you just want to hotlink it print out the html snippet(<img src="http

Copyright (C), All Rights Reserved.

processed in 0.175 (s). 11 q(s)