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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:26:45+00:00 2026-06-15T07:26:45+00:00

I have a custom listview adapter which contains ArrayList as a member. Each game

  • 0

I have a custom listview adapter which contains ArrayList as a member.

Each game belongs to a round.
I mean:

public class GameSummary
{
 String round;
 Game game;
}

So actually, I need to create sort of a section list view, which the round will be the header and the games below.

The problem is, that the listview engine generates row PER object in the array.

So if I will have 3 GameSummary and 10 Games in the array in it – It will generate only 3 rows!

What should I do ?

The current custom adapter inherites from BaseAdapter class.

  • 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-15T07:26:46+00:00Added an answer on June 15, 2026 at 7:26 am

    you have to use expandableListView and customAdapter like this.

    @SuppressLint("ResourceAsColor")
        public class ExpandableListAdapter extends BaseExpandableListAdapter {
    
    
            private LayoutInflater inflater;
            private ArrayList<GameSummary> mParent;
    
        public  ExpandableListAdapter(Context context, ArrayList<GameSummary> parent){
                this.mParent = parent;
                this.inflater = LayoutInflater.from(context);
            }
    
    
            //counts the number of group/parent items so the list knows how many times calls getGroupView() method
            public int getGroupCount() {
                return mParent.size();
            }
    
            //counts the number of children items so the list knows how many times calls getChildView() method
            public int getChildrenCount(int i) {
                return mParent.getGameList(i).size();
            }
    
            //gets the title of each parent/group
            public Object getGroup(int i) {
                return mParent.getGameList(i).getTitle(); //game Title
            }
    
            //gets the name of each item
            public Object getChild(int i, int i1) {
                return mParent.getGameList(i);
            }
    
            public long getGroupId(int i) {
                return i;
            }
    
            public long getChildId(int i, int i1) {
                return i1;
            }
    
            public boolean hasStableIds() {
                return true;
            }
    
    
            //in this method you must set the text to see the parent/group on the list
            public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
    
                if (view == null) {
                    view = inflater.inflate(R.layout.expandable_listview, viewGroup,false);
                }
    
                TextView textView = (TextView) view.findViewById(R.id.list_item_text_parent);
                //"i" is the position of the parent/group in the list
                textView.setText(getGroup(i).toString());
    
    
                //return the entire view
                return view;
            }
    
    
            //in this method you must set the text to see the children on the list
            public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
                if (view == null) {
                    view = inflater.inflate(R.layout.expandable_listview_child_item, viewGroup,false);
                }
    
                TextView textView = (TextView) view.findViewById(R.id.list_item_text_child);
                //"i" is the position of the parent/group in the list and 
                //"i1" is the position of the child
                textView.setText(mParent.get(i).getGameList(i1));
    
                //return the entire view
                return view;
            }
    
            public boolean isChildSelectable(int i, int i1) {
                return true;
            }
    

    and your class:

    public class GameSummary
    {
     String round;
     List<Game> gameList;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a custom listView which which extends ListActivity and each row contains
I have a custom ListView adapter which implements an ImageThreadLoader class. Unfortunately, the class
I have a custom ListView adapter which implements an ImageThreadLoader class. Unfortunately the class
I have a custom listview adapter which contains two buttons, the problem is it's
I have a ListView which uses a custom adapter as shown: private class CBAdapter
I have a custom adapter for my ListView which has multiple TextViews. I want
I have a ListView with custom adapter which is populated from local sqlite database.
I have listview with custom adapter. In each row i have 2 textviews and
I have a listview which contains custom rows. When I show the listview with
I have a custom ListView Adapter , with which I'm creating rows for a

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.