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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:16:48+00:00 2026-06-09T23:16:48+00:00

I am creating a ListView which as a TextView and ImageView as a list

  • 0

I am creating a ListView which as a TextView and ImageView as a list item row.

initially i am loading default items from local database in a listview view and I have a update button on the top of listview to load more items from server

when a user press an update button i am firing a AsyncTask which pull the icon urls and text from the server.

to load an icon in a ImageView i am using sample of ImageDownloader but the issues is my ImageView is getting overlapped with the old ImageViews bcoz of ViewHolder pattern. so can someone poit me what am i doing wrong ?

and here is my ListView Adapter code

@Override
public View getView(int position, View convertView, ViewGroup parent) {

                ViewHolder holder;
                TemplateData data = (TemplateData) this.getItem( position );

                if(convertView == null){
                    LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    convertView=inflater.inflate(R.layout.text_template_default_row, parent, false);

                    holder = new ViewHolder();
                    holder.templateText = (TextView) convertView.findViewById(R.id.defText);
                    holder.templateIcon = (ImageView)convertView.findViewById(R.id.defIcon);
                    holder.templateTitle = (TextView) convertView.findViewById(R.id.defTitle);

                    convertView.setTag(holder);

                }else{

                    holder = (ViewHolder)convertView.getTag();

                }


                holder.templateText.setText(data.getText() );
                holder.templateTitle.setText(data.getTemplateTitle());

                //isImageLoading initially sets to false so that default items will use the 
               // resource ids , it gets falsed when AsyncTask finished load Images and update the 
               //adapter and at that time this adapter has to pic the image from ImageDowloader
                if(!isImageLoading)
                    data.setTemplateIconId(iconList[position]);


                //Has resource id but not icon url
                if(data.getTemplateIconId()!=0 && data.getTemplateIconUrl()==null ){

                    Log.d("Load icon ","Default Load");

                    holder.templateIcon.setBackgroundResource(data.getTemplateIconId());



                // does not has recource id so load url from server
                }else if(data.getTemplateIconUrl()!=null && data.getTemplateIconId()==0){


                    Log.d("Load icon ","From Server Load");

                    imageDownloader.download(data.getTemplateIconUrl(), (ImageView) holder.templateIcon);



                }




                    return convertView;

         }

iconList contains the resources ids of existing icons in an application.
Please feel free to ask if someone wants more information.

EDIT

Here are the screen shots

Initially there will be 8 templates & its icon which are loading from database stored in a android phone only. its name start from template 1 to template 6

default view

now when a user presses update button new templates will be loaded over here. its name starts from template new 1 to template new 9 but the imageViews gets overlapped when i scroll up n down

here is the screen shots

enter image description here

  • 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-06-09T23:16:49+00:00Added an answer on June 9, 2026 at 11:16 pm

    I suspect that your imageDownloader is calling setImageResource (or equivalent–it’s setting the src attribute) of your ImageView, while you are initially calling setBackgroundResource. That would explain the overlap.

    What you need to do is change setBackgroundResource to setImageResource in the following code:

     if(data.getTemplateIconId()!=0 && data.getTemplateIconUrl()==null ){
    
                    Log.d("Load icon ","Default Load");
    
                    // This line should say setImageResource:
                    holder.templateIcon.setBackgroundResource(data.getTemplateIconId());
     } else ... 
    

    The issue that @Akos mentions (which he appears to have deleted) will be an issue for you if a download takes a long time and the view has already been reused. To restate what he stated, once you get this working via the solution above, you will find that if an image download takes a long time (so long that the row has already been reused, and the new image set) that your images may be overwritten with older images.

    Therefore, inside of imageDownloader you will also want to say, before downloading:

    imageView.setTag(url);
    

    and then after the download completes, before setting the image in the ImageView:

    if(!(String)imageView.getTag().equals(url)
    { 
         return; 
    }
    

    This way, if the ImageView has been reused by another row in the meantime, the download will simply abort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a ListView where each list item has a LinearLayout which I would
I am creating a simple RSS reader which displays headlines in ListView, downloading it
After creating a listview from VS2010 and adding it as a web part to
I'm creating a ListView that contains two TextViews and an ImageView. I'm passing data
I am creating a custom listview. The data is not coming from a cursor
I have a custom ListView Adapter , with which I'm creating rows for a
Actually i am creating an application in which i want to load images from
I seem to be having problem creating an adapter for listview to display items(Stuff
I am developing an application in android in which i creating a list view
I am creating a list view with each row having custom layout. Each custom

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.