Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7650635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:18:12+00:00 2026-05-31T11:18:12+00:00

I have a ListView than contains a list of image created from web link

  • 0

I have a ListView than contains a list of image created from web link (e.g. http://www...image.jpg) with the istruction:

Drawable d = LoadImageFromUrlWeb(TopTen_LinkImg);
imageTopTenView.setImageDrawable(d);

I have created a custom ArrayAdapter (both simple and optimized with “holder” same result).

The problem is that each image when appear in the display is uploaded from web and browse the page list is impossible (too slow).

There is a code that assign to ImageView the permanent image.

The code is:

public View getView(int position, View convertView, ViewGroup parent)
    {
    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.row_top_ten, null);
    ImageView imageTopTenView = (ImageView)rowView.findViewById(R.id.imageTopTen);
    String TopTen = (String)ArrayDatiTopTen.get(position);
    String[] ArrayTopTen=TopTen.split(",");
    String TopTen_LinkImg=(String)ArrayTopTen[0];
    Drawable d = LoadImageFromUrlWeb(TopTen_LinkImg);
    imageTopTenView.setImageDrawable(d);
    return rowView;
    }

Perhaps the solution is populate the listView using programmatically code:

ListView listView=(ListView) findViewById(R.id.listView);
...
listView.addView(...)
...

SOLVED

I have solved creating an Drawable array and filling this array with the image before use in ArrayAdapter

// Define:
Drawable imageCache[]=new Drawable[100];

then:

//loop to popolate array
imageCache[ct]=LoadImageFromUrlWeb(Link);

In the ArrayList I use:

...
imageTopTenView.setImageDrawable(imageCache[position]);
return rowView;
...

From url string to drawable:

private Drawable LoadImageFromUrlWeb(String url)
    {
        try
        {
            url=url.replaceAll(" ", "%20");
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "src name");
            return d;
        } 
        catch (Exception e)
        {
            Log.w("LoadImageFromUrlWeb",e.toString());
            return null;
        }
    }       
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:18:14+00:00Added an answer on May 31, 2026 at 11:18 am

    Brett’s answer is only half the solution, yes image downloading should be done asynchronously but you’ll end up repeatedly downloading the same image over and over again every time you scroll the listview due to the optimization of the listview.

    It reuses views so even if you downloaded an image and set it, if you scroll down several items that view will be reused and the image will have to be downloaded again when you scroll back up.

    To prevent this you will need image caching too. See this post on the android developer blog.

    Happily enough the code on the blog provides both asynchronous image downloading and image caching. Source code can be gotten from here

    (Note: You’ll need to make a slight change to the source code)

    Change Line 58 from

    private Mode mode = Mode.NO_ASYNC_TASK;
    

    to

    private Mode mode = Mode.CORRECT;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview ,each item is a textView with property autoLink=web|email.Link will work
I have dynamic listview on my android client app that receive data from remote
I have a problem with listview which list item contain a checkbox. When i
I have a ListView with a Button below it. When I fill the list
I have a rather complex ListView, with variable list item heights. Under certain conditions,
I have a ListView that I'm filling with an ObservableCollection I'm filtering the list
I have listview an i am populating it with songs from the sd card.
I have a ListView and the idea is that when the user types than
I have a listview with custom rows. In imageView1 I set an image, but
I have a view in my app which contains a ListView. Sometimes a row

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.