質問

In my app, getChildView() inside my ExpandableListAdapter isn't being called while the adapter returns the correct child count (when getChildrenCount() is called). My question is; what are the conditions that need to be met, in order to have ExpandableListAdapter inflate its children?

役に立ちましたか?

解決

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" />

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top