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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:26:10+00:00 2026-05-23T07:26:10+00:00

I have an ExpandableListView and an ExpandableListAdapter. When I call notifyDataSetChanged() in my adapter,

  • 0

I have an ExpandableListView and an ExpandableListAdapter. When I call notifyDataSetChanged() in my adapter, the data is not refreshed until I collapse and then expand the group. Here’s the code in question.

First, my activity (the relevant parts)

public class HomeActivity extends ExpandableListActivity {

Building of the adapter and list

homeList = (ExpandableListView)this.findViewById(android.R.id.list);
homeAdapter = new ExpandableHomeAdapter(this, profile.Statements, getItems(itemCount));
homeList.setAdapter(homeAdapter);
homeList.setIndicatorBounds(0,0);
homeList.setOnChildClickListener(this);

homeList.expandGroup(0);
homeList.expandGroup(1);

In this activity, I have an event that the activity is registered for that lets it know the model data (stored in the application controller), has changed. Here is that event.

private DataChangedListener dataChanged = new DataChangedListener() {

    @Override
    public void dataChanged(DataChangedEvent event, ChangeModel changes) {
        profile = Controller.getProfile();

        for (int x = 0; x < changes.NewItems.length; x++) {
            homeAdapter.insertItem(changes.NewItems[x], x);
        }

        for (int x = 0; x < changes.NewStatements.length; x++) {
            homeAdapter.insertStatement(changes.NewStatements[x], x);
        }

    }
};

And then there is my adapter

public class ExpandableHomeAdapter extends BaseExpandableListAdapter {

The insert method

public void insertItem(ItemSummary item, int index) {
    items.add(index, item);

    this.notifyDataSetChanged();
}

This same approach using the notifyDataSetChanged() worked when I was using multiple ArrayAdapters. Now, however, while everything works and the data is in fact changed, the screen does not update with the new data until I (manually) collapse and then expand the group. I haven’t tried programatically collapsing/expanding but I’d like to save that as a last resort. How do I get the view to update when the data changes?

  • 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-23T07:26:10+00:00Added an answer on May 23, 2026 at 7:26 am

    I think this is happening because of the way in which you’re inflating the ExpandableListView. Try this: Instead of doing a findViewById to grab the ELV, call the setContentView of the layout that contains the ExpandableListView. Then call:

     ExpandableListView homeList = getExpandableListView();
    

    Also, is there a way for you to call the notifyDataSetChanged() method from outside the class. Maybe you could call it from the same place you call the InsertItem method.

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

Sidebar

Related Questions

I have an ExpandableListView contains a link, it does not expand when has a
can we have ExpandableListView inside ListView so that I can have group level first
I have a ExpandableListView in which i am loading custom layouts in both group
Here is what I'm working with: I have an ExpandableListView that uses a SimpleCursorTreeAdapter
I have to delete child item in my expandablelistview. My attempt was: 1. Data
I have an Activity that sets an ExpandableListAdapter for an ExpandableListView. I would like
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp
have not tested on windows. but in ubuntu when u disconnect from the network,
I have the following problem: I would like to change value of ExpandableListView's cell
I have a simple ExpandalbeList. For the group header view, I'm using a simple

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.