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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:00:47+00:00 2026-05-26T04:00:47+00:00

I have an ExpandableListView in which if I add some Groups during onCreate() of

  • 0

I have an ExpandableListView in which if I add some Groups during onCreate() of the activity, it’s fine, but if I try to add Groups later on and then do notifyDataSetChanged() the ExpandableListView just freezes – everything else in the activity works, just the Exp.ListView hangs.

Here as you can see I add two Groups (with children) to the Exp.ListView and they function just fine. If I try to call addTeam() though it freezes/hangs.

package org.mytest;

import java.util.ArrayList;

import eigc.doubango.ScreenTeam.ScreenTeamItemGroup;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ImageButton;
import android.widget.ExpandableListView.OnGroupExpandListener;
import android.widget.ImageView;
import android.widget.TextView;

public class ScreenTeam extends Activity {
private TeamListAdapter mTeamListAdapter;
private ExpandableListView mTeamList;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen_team);

        mTeamListAdapter = new TeamListAdapter(getLayoutInflater());
        mTeamList =  (ExpandableListView) findViewById(R.id.screen_team_teamslist);
        mTeamList.setAdapter(mTeamListAdapter);
        mTeamList.setGroupIndicator(null);




        /* TEST */

        ScreenTeamItemGroup grp1 = new ScreenTeamItemGroup("team1",1);
        ScreenTeamItemChild ch1 = new ScreenTeamItemChild("child1");
        ScreenTeamItemChild ch2 = new ScreenTeamItemChild("child2");
        grp1.addTeamMember(ch1);
        grp1.addTeamMember(ch2);

        ScreenTeamItemGroup grp2 = new ScreenTeamItemGroup("team2",2);
        ScreenTeamItemChild ch3 = new ScreenTeamItemChild("child1");
        ScreenTeamItemChild ch4 = new ScreenTeamItemChild("child2");
        ScreenTeamItemChild ch5 = new ScreenTeamItemChild("child3");
        grp2.addTeamMember(ch3);
        grp2.addTeamMember(ch4);
        grp2.addTeamMember(ch5);

        mTeamListAdapter.addTeam(grp1);
        mTeamListAdapter.addTeam(grp2);
    }



    /*
     * Callbacks
     */

    /* adds a team */
    public void addTeam() {
        ScreenTeamItemGroup grp1 = new ScreenTeamItemGroup("team1",1);
        ScreenTeamItemChild ch1 = new ScreenTeamItemChild("child1");
        ScreenTeamItemChild ch2 = new ScreenTeamItemChild("child2");
        grp1.addTeamMember(ch1);
        grp1.addTeamMember(ch2);
        mTeamListAdapter.addTeam(grp1);
        mTeamListAdapter.notifyDataSetChanged();
    }





    /*
     * Aux classes
     */
    /* team group item */
    static class ScreenTeamItemGroup {
        final String mItemText;
        final int mIconResId;
        final int mTeamID;
        public ArrayList<ScreenTeamItemChild> mTeamMembers; 

        public ScreenTeamItemGroup(String itemText, int id) {
            mItemText = itemText;
            mTeamID = id;
            mIconResId = R.drawable.teams;
            mTeamMembers = new ArrayList<ScreenTeamItemChild>();
        }

        public void addTeamMember(ScreenTeamItemChild member) {
            if (member != null)
                mTeamMembers.add(member);
        }
    }

    /* team child item */
    static class ScreenTeamItemChild {
        final int mIconResId;
        final String mItemText;

        public ScreenTeamItemChild(String itemText) {
            mIconResId = R.drawable.p2p;
            mItemText = itemText;
        }
    }

    /* handles the list of teams */
    static class TeamListAdapter extends BaseExpandableListAdapter {
        public ArrayList<ScreenTeamItemGroup> mTeams;
        private final LayoutInflater mInflater;

        public TeamListAdapter(LayoutInflater inflater) {
            mInflater = inflater;
            mTeams = new ArrayList<ScreenTeamItemGroup>();
        }

        @Override
        public Object getChild(int groupPosition, int childPosition) {
            return mTeams.get(groupPosition).mTeamMembers.get(childPosition);
        }

        @Override
        public long getChildId(int groupPosition, int childPosition) {
            return childPosition;
        }

        @Override
        public View getChildView(int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
            View view = convertView;
            final ScreenTeamItemChild item = (ScreenTeamItemChild)getChild(groupPosition,childPosition);

            if(item == null){
                return null;
            }
            if (view == null) {
                view = mInflater.inflate(R.layout.screen_team_item, null);
            }
            ((TextView) view.findViewById(R.id.screen_team_item_text)).setText(item.mItemText);
            ((ImageView) view.findViewById(R.id.screen_team_item_icon)).setImageResource(item.mIconResId);

            return view;
        }

        @Override
        public int getChildrenCount(int groupPosition) {
            return mTeams.get(groupPosition).mTeamMembers.size();
        }

        @Override
        public Object getGroup(int groupPosition) {
            return mTeams.get(groupPosition);
        }

        @Override
        public int getGroupCount() {
            return mTeams.size();
        }

        @Override
        public long getGroupId(int groupPosition) {
            return groupPosition;
        }

        @Override
        public View getGroupView(int groupPosition, boolean isExpanded,
                View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            View view = convertView;
            final ScreenTeamItemGroup item = (ScreenTeamItemGroup)getGroup(groupPosition);

            if(item == null){
                return null;
            }
            if (view == null) {
                view = mInflater.inflate(R.layout.screen_team_item, null);
            }
            ((TextView) view.findViewById(R.id.screen_team_item_text)).setText(item.mItemText);
            ((ImageView) view.findViewById(R.id.screen_team_item_icon)).setImageResource(item.mIconResId);
            return view;
        }

        @Override
        public boolean hasStableIds() {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            // TODO Auto-generated method stub
            return false;
        }

        public void addTeam(ScreenTeamItemGroup grp) {
            if (grp != null)
                mTeams.add(grp);
        }

    }
}
  • 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-26T04:00:48+00:00Added an answer on May 26, 2026 at 4:00 am

    I solved this by using runOnUiThread in my addTeam() instead and it worked flawlessly.

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

Sidebar

Related Questions

I have a ExpandableListView in which i am loading custom layouts in both group
Im trying to implement an activity that uses ExpandableListView and I have gotten so
I have an ExpandableListView and an ExpandableListAdapter. When I call notifyDataSetChanged() in my adapter,
I have an AlertDialog populated by an ExpandableListView. The list itself works perfectly, but
I have an activity that extends ExpandableListActivity. I use SimpleCursorTreeAdapter to fill ExpandableListView. My
guys i have 3 groups for my expandable listview, i try to change the
I have an ExpandableListView that uses a SimpleCursorTreeAdapter which uses the cursors returned by
I have an ExpandableListView view and I've implemented OnChildClickListener , but I need to
I can't create layout in which I will have <LinearLayout> <TextView/> <ExpandableListView/> <Button/> </LinearLayout>
I have an ExpandableListView (ELV) with the groups having LinearLayout. I have set the

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.