On what conditions getChildView() is called in ExpandableListAdapter

霸气de小男生 提交于 2019-12-05 13:56:16

is called when you have more than 1 item in groups and in childs, i mean when getGroupCount returns a value greater than 0

getGroupCount() method tells you how many groups will be there in you ExpandableListView and getChildrenCount(int groupPosition) method tells you how many child will be there for the respective group. So untill getChildrenCount method returns 1 or greater than 1 value, till than no child views will be visible.

One more thing which is also really matters when your child Views not getting visible is "height of Expandable Listview must be match_parent, if your expandable list view is within any other layout then that layout height should also be match_parent."

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

The exact problem is with the android:layout_height="" of your expandable list view that cuts of the childs.

Use this as the 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" />

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!