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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:31:11+00:00 2026-06-14T15:31:11+00:00

I will be very grateful if someone can help me one this :) I

  • 0

I will be very grateful if someone can help me one this 🙂

I have a Custom Adapter (extending ArrayAdapter), and on the objects it displays (movieDatas), there is a property that vary with time (downloadProgress)

Since I use this adapter in multiple places, I wondered wether it is possible for my CustomAdapter to listen to every movieDatas.downloadProgress property, and then update itself ? Thus, not using ArrayAdapter.notifyDataSetChanged from the activity, but the adapter would take the decision to update by itself.

Previously, I used a Timer on every Activity that called myListView.invalidate() every 5 seconds, but I wondered if the adapter could handle the changes by itself ?

Thank you very much for your help, I begin in android development.

  • 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-14T15:31:12+00:00Added an answer on June 14, 2026 at 3:31 pm

    I don’t know how you’re doing it, but it sounds like you could totally use a callback to implement it.

    1) Create an interface like this:

    public interface OnDownloadProgressChangeListener{
        public void onProgress(int progress);
    }
    

    2) Add this to your MovieData object:

    // We use an ArrayList because you could need to listen to more than one event. If you are totally sure you won't need more than one listener, just change this with one listener 
    private ArrayList<OnDownloadProgressChangeListener> listeners = new ArrayList<OnDownloadProgressChangeListener>();
    
    public void addDownloadProgressChangeListener(OnDownloadProgressChangeListener listener){
        listeners.add(listener);
    }
    
    public void clearDownloadProgerssChangeListeners(){
        listeners.clear();
    }
    
    //Add any handlers you need for your listener array.
    
    
    // ALWAYS use this method to change progress value.
    public void modifyProgress(int howMuch){
         progress+=howMuch;
         for (OnDownloadProgressChangeListener listener : listeners)
              listener.onProgress(progress);
    }
    

    3) Override your custom adapter add method

    @Override
    public void add(final MovieData item){
        item.addDownloadProgressChangeListener(new OnDownloadProgressChangeListener(){
            public void onProgress(final int progress){
                 // Add your logic here
                 if (progress == 100){
                      item.update();
                 }
            }
        });
        super.add(item);
    }
    

    4) Whenever an item gets modified, call notifyDataSetChanged() on your adapter. You can even add it after the super.add(item) line in the add implementation, but this is extremely inefficient if you’re going to add a lot of items: Add them first then notify the changes.

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

Sidebar

Related Questions

I will be very, VERY grateful if someone can help me figure out my
I would be so very grateful if someone could help me out! I have
This is driving me crazy. Very grateful if someone could help me out! Problem:
Anyone that can help me out will be very much appreciated. I seem to
there's this interesting problem i can not solve myself. I will be very glad,
Can someone help me with this issue? I currently working on my project for
I really hope someone will be able to help me out with this. I
I got another libgit2 issue and will be very grateful for your help. I'm
I will be very grateful, if somebody can actually explain what exactly my compiler
I'm sure this will be very simple for you experts. SUDZC is set up

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.