Expandable List with image on child items

My app has expandable list with “Items” and “categories”.

This example helped my implementation.


I had to extend adapter class and I overwrote only one method: getChildView. I had to add constructor that matches what’s already in code and call super on it.

That’s all folks.

How to highlight item in expandable list view

When screen opens I want to have last item be highlighted and group expanded.


-----------------------selector_list_item.xml in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"

   <item android:drawable="@android:color/holo_blue_bright" android:state_pressed="true"/>
   <item android:drawable="@android:color/holo_blue_light" android:state_selected="true"/>
   <item android:drawable="@android:color/holo_blue_dark" android:state_activated="true"/>

----------------------- add this to my list

android:listSelector = “@drawable/selector_list_item”


Try it:


public boolean onChildClick(ExpandableListView lView, View v,
        int groupPosition, int childPosition, long id) {
// or another place
    int index = lview.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition));
    lview.setItemChecked(index, true);

    return true;

this didn't compile. Another option, checking for null bc during onCreate lView is still null
2. this didn't d oanything, nothing visible

if (lView != null){
selectChildInParent, true);


lView = this.getExpandableListView();
int count = listAdapter.getGroupCount();
for (int position = 1; position <= count; position++)
((ExpandableListView) lView).expandGroup(position – 1);

4. NONE of these worked for me. It does nothing.

However seems like for everyone else at stackoverflow this was not a problem. Case remains open.

ListView with expandable groups (categories)

English: Food2u running on an Android phone. E...

English: Food2u running on an Android phone. Español: Food2u funcionando en un teléfono Android. (Photo credit: Wikipedia)

Discovery one for today: setting table id as  autoincrement crashes code.  According to docs if field is declared as primary key it will autoincrement by itself. I wonder, why did they decide to crash it, they could have ignored the key word. Anyhow.

The next task is to create categories for input. Design considerations:

Input will be dropdown in the Edit screen with predefined enums. How would I show groups on a front screen? List with categories would be nice.  I’d   to reserve tabs for implementation of multi users.

Let’s explore lists with categories.

There is ExpandableListView

Replaced my old

android:layout_height=”289dp” >


android:layout_height = “match_parent”
</ExpandableListView >

I have to replace ListAdapter with ExpandableListAdapter in java code. reading http://developer.android.com/reference/android/widget/SimpleExpandableListAdapter.html

This example seems to be what I need


Lunch stop. Stuck on creating this adapter. WTF is groupFrom and groupTo?

After 2 h successfully implemented expandable adapter. Took while to understand what these maps are but I got it!

After my expandable list started to work each time keyboard comes up at a startup. Found a fix by adding this line to manifest as property of this activity  android:windowSoftInputMode=”stateHidden”.


this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); or


Tomorrow is all about stabilization.

Other generally useful


Found info on testing . people say  You should have three (3) different devices:
1. One mobile phone (small screen) with Android 2.3 (e.g. HTC Wildfire)
2. One mobile phone (small screen) with Android 4.0+ (e.g. Samsung galaxy s3, s4)
3. One tablet (big screen > 7”) (e.g. Samasung galaxy Note 10.1)

ANother example of expandable list adapter but even less understandable