Hi all,
i have a strange problem regarding the item order in an
ExpandableListView. When the activity containing the ListView starts
all items (group items and second-level items) are in the right order.
After expanding and collapsing a group item the selected group item
suddenly jumps to the end of the list and one of the child items
becomes a group item. While continiously clicking on the topmost group
item the original group item step by step moves to the top of the list
and eventually becomes a group item again.
Below is the code of my Activity:
public class UserListActivity extends ExpandableListActivity {
private static final int MENU_UPDATE = Menu.FIRST;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.user_list);
}
@Override
protected void onResume() {
super.onResume();
// Query for people
String projection[] = new String[] { Proxity.Groups._ID,
Proxity.Groups.NAME, Proxity.Groups.DESCRIPTION,
Proxity.Groups.GROUP_ID };
Cursor groupCursor = managedQuery(Proxity.Groups.CONTENT_URI,
projection, null, null, null);
// Set up our adapter
GroupUserAdapter adapter = new GroupUserAdapter(this,
groupCursor,
android.R.layout.simple_expandable_list_item_2,
new String[] { Proxity.Groups.NAME,
Proxity.Groups.DESCRIPTION },
new int[] { android.R.id.text1, android.R.id.text2 },
R.layout.user_item,
new String[] { Proxity.Users.NAME },
new int[] { R.id.name_view });
setListAdapter(adapter);
}
private class GroupUserAdapter extends SimpleCursorTreeAdapter {
public GroupUserAdapter(Context context, Cursor cursor, int
groupLayout,
String[] groupFrom, int[] groupTo, int childLayout,
String[] childFrom, int[] childTo) {
super(context, cursor, groupLayout, groupFrom, groupTo,
childLayout,
childFrom, childTo);
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
String groupId =
groupCursor.getString(groupCursor.getColumnIndex(Proxity.Groups.GROUP_ID));
String projection[] = { Proxity.Users._ID,
Proxity.Users.NAME, Proxity.Users.DATA };
String where = Proxity.Users.GROUP_ID + "=\"" + groupId + "\"";
Cursor cursor = managedQuery(Proxity.Users.CONTENT_URI,
projection,
where, null, null);
return cursor;
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---