Sie sollten eine Klasse haben alle implementierten Methoden der ExpandableListAdapter
mit sowie ChildItemsInfo
Klasse und eine GroupItemsInfo
Klasse, mit MainActivity
mit den Klick-Listener zu gruppieren Elemente und ihre Kinder
... jetzt genauer zu sein ...
du innerhalb getGroupView()
platzieren können, die innerhalb MyExpandableListAdapter
Klasse ist
View ind = convertView.findViewById(R.id.group_indicator);
View ind2 = convertView.findViewById(R.id.group_indicator2);
if (ind != null)
{
ImageView indicator = (ImageView) ind;
if (getChildrenCount(groupPosition) == 0)
{
indicator.setVisibility(View.INVISIBLE);
}
else
{
indicator.setVisibility(View.VISIBLE);
int stateSetIndex = (isExpanded ? 1 : 0);
/*toggles down button to change upwards when list has expanded*/
if(stateSetIndex == 1){
ind.setVisibility(View.INVISIBLE);
ind2.setVisibility(View.VISIBLE);
Drawable drawable = indicator.getDrawable();
drawable.setState(GROUP_STATE_SETS[stateSetIndex]);
}
else if(stateSetIndex == 0){
ind.setVisibility(View.VISIBLE);
ind2.setVisibility(View.INVISIBLE);
Drawable drawable = indicator.getDrawable();
drawable.setState(GROUP_STATE_SETS[stateSetIndex]);
}
}
}
... und wie sie für die Layout-Ansicht, das ist, wie meine group_items. xml erscheint
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/group_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:textSize="15sp"
android:textStyle="bold"/>
<ImageView
android:id="@+id/group_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/arrow_down_float"
android:layout_alignParentRight="true"
android:paddingRight="20dp"
android:paddingTop="20dp"/>
<ImageView
android:id="@+id/group_indicator2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/arrow_up_float"
android:layout_alignParentRight="true"
android:visibility="gone"
android:paddingRight="20dp"
android:paddingTop="20dp"/>
nicht klar genug sein ?, kommentieren, wenn
Was sind 'groupItem' und' childItem'. Was ist NewAdapter und wie behandelt es 'groupItem' und' childItem', um einige Elemente erweiterbar zu machen? Deine Antwort ist unvollständig. –
groupItem ist ein Array, das Strings für jede Gruppenoption enthält. "TopView 2" in der obigen Grafik. childItem ist eine Matrix/hashmap, die eine Liste von Elementen enthält, die nach dem Auswählen der einzelnen Gruppenelemente abgelegt werden sollen. NewAdapter ordnet die Werte von groupItem- und childItem-Datasets Ansichten zu, wenn der Halter jedes Elements aufgebläht wird. – AlleyOOP