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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:00:44+00:00 2026-06-10T08:00:44+00:00

I saw that there were many problems regarding notifyDataSetChanged(). I’ve looked through many of

  • 0

I saw that there were many problems regarding notifyDataSetChanged(). I’ve looked through many of them and none of the solutions worked for me.

I am using ArrayList to set my list, and after my ArrayList is updated, i ran notifyDataSetChanged(). The new list is added onto the previous one.

lets say first list is a,b and new list is a,b,c. what i get in the end is a,b,a,b,c.
and each time updating this happens again with the new list.

I’ve tried other such as invalidate(), adapter clear(), refreshDrawableState() etc and nothing worked.

Thank you in advance.

Here is the simplified code, a note that changing MainActivity extends Activity to ListActivity crashes the program even after i change the code in .xml file.

public class MainActivity extends Activity 
{
ArrayList<String> names = new ArrayList<String>();
ArrayAdapter arrayAdapter = null;

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    ListView lv1 = (ListView) findViewById(R.id.listview);
    arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, names);
    lv1.setAdapter(arrayAdapter);

}

//code here to edit the ArrayList names.

public void onResume() 
{
    super.onResume();  // Always call the superclass method first

    //the activity need to be updated everytime it resumes.
    arrayAdapter.notifyDataSetChanged();

}
}
  • 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-10T08:00:45+00:00Added an answer on June 10, 2026 at 8:00 am

    Seems like you are not properly updating the array list. Please try logging the array list contents after updating.

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

Sidebar

Related Questions

I'm using the MSChart Control in a Web Project. I saw that there are
I saw that there's many, many thread about this on the web, also in
I know that Namespaces in PHP are relatively new and so there are many
I have been reading through the specification of openGL 1.5, and saw that any
First of all I have seen that there are many questions about unrecognized selector
I saw in a Dr Dobb's email report for 2008-12-29 that there's a new
I saw that even by writing separate commands, we can combine two different types
I saw that the Alfresco Cloud edition has nice share/publish features: (source: alfresco.com )
I saw that to show a JOptionPane message dialog I need the shutdownHooks permition.
I saw that one of our tools uses a ConsoleAppender to System.err next to

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.