Under what conditions getChildView () is called in ExpandableListAdapter

In my application, getChildView() inside my ExpandableListAdapter is not called until the adapter returns the correct count of children (when getChildrenCount() is called). My question is: what are the conditions that must be met for the ExpandableListAdapter to inflate its children?

+4
source share
3 answers

called when you have more than one element in groups and in children, I mean when getGroupCount returns a value greater than 0

+1
source

The getGroupCount () method tells you how many groups will be present in you. The ExpandableListView and the getChildrenCount (int groupPosition) method indicate how many children will be there for the corresponding group. Therefore, if the getChildrenCount method does not return a value of 1 or greater than 1, then until the child views are visible.

Another thing that also matters when your child view does not become visible is "height of Expandable Listview should be match_parent, if your extended list view is in any other layout, then the height of the layout should also be match_parent."

0
source

Your problem is not getChildView (), my friend, this is definitely with the layout.

The exact problem is android: layout_height = "" your extensible list, which cuts off the children.

Use this as a layout:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#FFFFFF" tools:context="/*your activity*/" > <ExpandableListView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:childDivider="@android:color/transparent" android:dividerHeight="0dp" /> 

-2
source

Source: https://habr.com/ru/post/1496209/


All Articles