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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s