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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:56:48+00:00 2026-05-31T20:56:48+00:00

I implemented ArrayAdapter for ListView , where each row contains TextView and ImageButton .

  • 0

I implemented ArrayAdapter for ListView, where each row contains TextView and ImageButton.
The background image of ImageButton depends on some condition, two options are available:

public View getView(int position, View convertView, ViewGroup parent) {
            View vi=convertView;
            if(convertView==null)
                vi = inflater.inflate(R.layout.item_with_button, null);

            File f = new File(PATH_TO_FILE);
            if(f.exists()){
                imbutton =(ImageButton)vi.findViewById(R.id.btn_image);
                imbutton.setBackgroundResource(R.drawable.done);
            }else
            {
                imbutton =(ImageButton)vi.findViewById(R.id.btn_image);
                imbutton.setBackgroundResource(R.drawable.download);
                imbutton.setOnClickListener(new View.OnClickListener() {        
                    public void onClick(View v) {
                        String url = URL;
                        new DownloadFileAsync(pos).execute(url);
                    }
                });
            }
... 
return vi;
}

If file exists, then I set “done” image on ImageButton. If file doesn’t exist, I set “download” image.

After user clicks on ImageButton, the file downloads and I need change respective image.
The problem is that getView is called only if user scrolls ListView down until this ImageButton dissapear from the screen and then scroll back. After that button appears with new background image.

However, I can’t invalidate button to display new image at the moment.

I used this class for async downloading: http://www.java-samples.com/showtutorial.php?tutorialid=1521

I tried make something like currentbutton.invalidate() in function

@Override
protected void onPostExecute(String unused) {
       activity.dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
}

but without success.

How can I invalidate ImageButton to display its new background image?

  • 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-31T20:56:50+00:00Added an answer on May 31, 2026 at 8:56 pm

    You could call notifyDataSetChanged in the onClick listener to force a refresh on the list.
    I haven’t tried it though, so I’m not sure if it’ll work without making any explicit changes on the adapter(i.e. adding, removing or updating items on it).

    I’ll check it later and write any further suggestions if it doesn’t work out of the box.

    EDIT: Actually you need to call notifyDataSetChanged in the onPostExecute method of the AsyncTask you are using, not in the onClick listener.

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

Sidebar

Related Questions

I want to use a listview with checkboxes and some other options with out
I have a listview, with around 200 items, I have implemented a custom ArrayAdapter
I use an ArrayAdapter to show items in a ListView. Every row in this
I implemented a small OOP library in Lua, and two things are not quite
Already implemented performance boosters : - Get compatible image of GraphicsConfiguration to draw on
I have implemented an application on ListView in my application i have used getListView()
I want to implement RadioButton and EditText inside a row of a ListView. I
I'm trying to filter my ListView which is populated with this ArrayAdapter: package me.alxandr.android.mymir.adapters;
I have this Code to Capture a image and Display it back in ListView
In my application, I have ListView which is set by my CustomAdapter (i.e. ArrayAdapter).

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.