You must have a class that has all the implemented ExpandableListAdapter methods, as well as the ChildItemsInfo class and the GroupItemsInfo class, while MainActivity has click listeners for grouping elements and their children
... now more specifically ...
You can put this in getGroupView() inside the MyExpandableListAdapter class
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); 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]); } } }
... and as for the layout view, here is what my group_items.xml looks like
<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"/>
Fuzzy enough ?, comment when
keyboard_kracker22
source share