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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:46:39+00:00 2026-06-06T12:46:39+00:00

I want to do something like this. while pressing the refresh button, it will

  • 0

I want to do something like this.

while pressing the refresh button, it will refresh the list. Activity codes are like this:

        adapter = new TweetAdapter(Welcome.this, tweets, users);
        tweetsList.setAdapter(adapter);


    private void refreshAdapter() {
        adapter.clear();
        adapter.refresh(tweets, users);
    }

refreshAdapter() called when I need to change the list item. here tweets & users are ArrayList & HashMap items

and the adapter part is like this:

public void clear() {
    this.tweets.clear();
    this.users.clear();
}

public void refresh(ArrayList<Tweet> tweets, HashMap<String, User> users) {
    this.tweets.addAll(tweets);
    this.users.putAll(users);
    Collections.sort(this.tweets, new TweetTimeComparator());
    notifyDataSetChanged();
}

but unfortunately notifyDataSetChanged(); is not working. by clicking refresh the list either turns black(maximum time) or have no response(some time).

please tell me if you find the error or suggest me what to do.

  • 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-06T12:46:41+00:00Added an answer on June 6, 2026 at 12:46 pm

    I think you are clearing the data

    this.tweets.clear();
    this.users.clear();
    

    ..
    I think as tweets and users both has same refreance ( as passed from activity to adapter ) so both tweets and both users (on adapter and on activity are pointing to same ArrayLists) so both are get-clear so these line not make sense as both are empty

    this.tweets.addAll(tweets);
    this.users.putAll(users);
    

    try

    public TweetAdapter(Context context, ArrayList<Tweet> tweets, HashMap<String, User> users) { 
    
    mInflater = LayoutInflater.from(context); 
    this.tweets = new ArrayList<Tweet>(); 
    this.users = new HashMap<String, User>();
    
    this.tweets.addAll(tweets);
    this.users.putAll(users);
    
    Collections.sort(this.tweets, new TweetTimeComparator()); 
    } 
    

    ..

    public void refresh(ArrayList<Tweet> tweets, HashMap<String, User> users) {
    
      this.tweets.clear();
        this.users.clear();
    
        this.tweets.addAll(tweets);
        this.users.putAll(users);
        Collections.sort(this.tweets, new TweetTimeComparator());
        notifyDataSetChanged();
    }
    

    but NOTE : now reference to both tweets (on adapter and on activity) and both users (on adapter and on activity) are different.

    There should no direct assignment like adapter.tweets = activity.tweets any where other use this.tweets.addAll(tweets);

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

Sidebar

Related Questions

I want something like this: public void CopyIteratorIntoList(Iterator<Foo> fooIterator) { List<Foo> fooList = new
I want to create something like this |Button| item 1 item 2 item 3
My whole purpose of this is to get something looking like this: I want
I want something like this: abcdab.search(/a/g) //return [0,4] Is it possible?
I want to do something like this: {% set c=a+b %} Where a and
I want to do something like this, where Foo is a class with one
I want to reach something like this: if(window.location.href.indexOf(http://stackoverflow.com/questions/)){ ... then to this } but
I want to do something like this: <c:if test=${somestring.charAt(0)=='1'}> tadaaaam </c:if> when somestring is
I want to do something like this but i dont know how to: $file=4
I want to do something like this, but I'm not sure if it is

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.