Expandable List with image on child items

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

This example helped my implementation.

http://theopentutorials.com/tutorials/android/listview/android-expandable-list-view-example/

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"
   android:exitFadeDuration="@android:integer/config_mediumAnimTime">

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

</selector>
----------------------- add this to my list

android:listSelector = “@drawable/selector_list_item”

————————————-

Try it:

1.

@Override
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){
((ExpandableListView)lView).setSelectedChild(selectParent,
selectChildInParent, true);
}

3.

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

<ListView
android:id=”@android:id/list”
android:layout_width=”match_parent”
android:layout_height=”289dp” >
</ListView>

with

<ExpandableListView
android:id=”@android:id/list”
android:layout_width=”match_parent”
android:layout_height = “match_parent”
android:background=”#00FF00″
android:layout_weight=”1″
android:drawSelectorOnTop=”false”>
</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

http://www.edumobile.org/android/android-game-programming/simple-expandable-list-example/

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”.

And

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

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

Tomorrow is all about stabilization.

Other generally useful

http://developer.android.com/distribute/googleplay/publish/preparing.html

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