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 6189993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:30:30+00:00 2026-05-24T02:30:30+00:00

Currently I face the following issue – I create a custom ListView ( 1

  • 0

Currently I face the following issue – I create a custom ListView (1 x ImageView + 2 x TextView). It displays content from I-net, which is an XML file.

What am I doing – I’m using AsyncTask to run in background the process of downloading the XML content and filling up the ListView by calling publishProgress(…) method for each and every list item from doInBackground(…) method. When the doInBackground(…) completes I already had collected the URL of each and every image I want to display and then from onPostExecute(…) method I start download process for the images and update the UI for every downloaded image. The problem for me is that the ListView should fill up at least a few items before to start download an drawable file and update the list. Currently the ListView shows a single item and when fill next one, all images are already downloaded. I debug the app and I saw that one I stop in onPostExecute(…) method and want to take the number of ListView items, it’s return just one, as it displays.

Is there a way to force appearance Listview‘s items, before to start the download or this because the I-net connection, that I have, is gut enough and there is not delay by downloading the images.

I forget only to mention that each and every image is not bigger then a 10KB.

This is my custom AsyncTask:

private class DownloadFilesTask extends AsyncTask<String, Object, List<RSSItem>> {
        protected void onPreExecute() {
            super.onPreExecute();

            la.clear();
        }
        protected List<RSSItem> doInBackground(String... urls) {
            parse(urls[0]);

            if (feed == null) { return null; }

            rssList = feed.getAllItems();
            Iterator<RSSItem> iterator = rssList.iterator();

            while(iterator.hasNext()) {
                if (isCancelled()) return null; 
                RSSItem rss = iterator.next();
                publishProgress(rss);
            }

            return rssList;
        }
        protected void onProgressUpdate(Object... progress) {
            super.onProgressUpdate(progress);

            la.add((RSSItem)progress[0]);
            la.notifyDataSetChanged();
        }
        protected void onPostExecute(List<RSSItem> result) {
            super.onPostExecute(result);

            Drawable downloadedImage;
            for (int z = 0; z < rssList.size(); z++) {
                downloadedImage = downloadImage(rssList.get(z).getImageURL());
                ((RSSItem)rssList.get(z)).setImage(downloadedImage);
                la.notifyDataSetChanged();
            }
        }
        protected void onCancelled() {
            super.onCancelled();
        }
    }

Here is the custom Listadapter:

private class ListAdapter extends ArrayAdapter<RSSItem> {

        private List<RSSItem> items;

        public ListAdapter(Context context, int textViewResourceId, List<RSSItem> items) {
            super(context, textViewResourceId, items);
            this.items = items;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;

            if (v == null) {
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.list_item, null);
            }

            RSSItem item = items.get(position);

            if (item != null) {
                ImageView itemImage = (ImageView) v.findViewById(R.id.ivImage);
                TextView title = (TextView) v.findViewById(R.id.tvTitle);
                TextView description = (TextView) v.findViewById(R.id.tvDescription);
                if (item.getImage() != null) {
                    itemImage.setBackgroundDrawable(item.getImage());
                } else {
                    itemImage.setBackgroundDrawable(getResources().getDrawable(R.drawable.icon));
                }
                if (title != null) {
                    title.setText(item.getTitle());
                }
                if (description != null) {
                    description.setText(item.getDescription());
                }
            }

            return v;
        }
    }

…and the Item class:

public class RSSItem {
    private String data = null;
    private String description = null;
    private Drawable image = null;
    private String imageUrl = null;
    private String title = null;

    RSSItem() {
    }

    public void setData(String data) {
        this.data = data;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setImageURL(String imageURL) {
        this.imageUrl = imageURL;
    }

    public void setImage(Drawable image) {
        this.image = image;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getData() {
        return data;
    }

    public String getDescription() {
        return description;
    }

    public Drawable getImage() {
        return image;
    }

    public String getImageURL() {
        return imageUrl;
    }

    public String getTitle() {
        return title;
    }
}

@MODIFICATIONS:

private class DownloadFilesTask extends AsyncTask> {
protected void onPreExecute() {
super.onPreExecute();

        la.clear();
    }

    protected List<RSSItem> doInBackground(String... urls) {
        parse(urls[0]);

        if (feed == null) { return null; }

        rssList = feed.getAllItems();
        publishProgress(true);

        Drawable downloadedImage;
        for (int z = 0; z < rssList.size(); z++) {
            downloadedImage = downloadImage(rssList.get(z).getImageURL());
            ((RSSItem)rssList.get(z)).setImage(downloadedImage);
        }
        return rssList;
    }

    protected void onProgressUpdate(Object... progress) {
        super.onProgressUpdate(progress);

        la.notifyDataSetChanged();
    }

    protected void onPostExecute(List<RSSItem> result) {
        super.onPostExecute(result);

        la.notifyDataSetChanged();
    }

    protected void onCancelled() {
        super.onCancelled();
    }
}
  • 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-24T02:30:30+00:00Added an answer on May 24, 2026 at 2:30 am

    I’m not sure I understand your issue, but what I would do is the following (if I got it right):

    I suppose you have a custom Object that you store in your ListView, let’s say CustomItem.
    I would place the download of the URL Image in the constructor of that object, and store the Drawable as a member of your CustomItem. And just after you have created a new CustomItem and got the image for it, publishProgress() and call notifyDataSetChanged() on your list adapter.

    EDIT: You should move the code from the onPostExecute() method at the end of your doInBackground() method.

    Try this:

    private class DownloadFilesTask extends AsyncTask<String, RSSItem, Void> {
        protected void onPreExecute() {
            super.onPreExecute();
            la.clear();
        }
        protected List<RSSItem> doInBackground(String... urls) {
            parse(urls[0]);
    
            if (feed == null) { return null; }
            rssList = feed.getAllItems();
            Iterator<RSSItem> iterator = rssList.iterator();
    
            while(iterator.hasNext()) {
                if (isCancelled()) return null; 
                RSSItem rss = iterator.next();
                //this happens fast no need to do this
                publishProgress(rss);
                //la.add(rss);
            }
            Drawable downloadedImage;
            for (int z = 0; z < rssList.size(); z++) {
                downloadedImage = downloadImage(rssList.get(z).getImageURL());
                ((RSSItem)rssList.get(z)).setImage(downloadedImage);
                publishProgress(null);
            }
            return rssList;
        }
        protected void onProgressUpdate(RSSItem... progress) {
            super.onProgressUpdate(progress);
            if progress!=null
               la.add((RSSItem)progress[0]);
            la.notifyDataSetChanged();
        }
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
    
        }
        protected void onCancelled() {
            super.onCancelled();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm doing some unit tests which are executed from bash. Unit tests are
Does anybody know which,currently,is the best library for realizing a real time face-tracking solution
I am currently trying to find the face in a particular image.I am following
Currently IIS sends an expires http header of yesterday minus 1 hour on ASP.NET
I am doing a project that recognize human face from camera. Here is the
We currently have a solution that was completely written by hand in ASP.NET and
I am currently in the process of removing html tags from fields within an
i am currently having trouble with my object rotating to face another object.currently it
I'm currently studying for an exam (which is in two days) for computer vision
If .emacs contains the following two lines (set-face-foreground 'modeline #000000) (set-face-background 'modeline #00FFFF) then

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.