I just started working with expandablelists in android 2.2 and I have run into this same problem. I never used them in prior versions of android, but I just fired up an emulator with 1.6 and saw that the setSelectedGroup() function did exactly what I wanted. Did you come up with a solution? I looked into the "smoothScroll" functions, but it seems like they are not implemented in the ExpandableListView class. There also seems to be a bug with the "smoothScroll" functions in regular listviews as well, http://code.google.com/p/android/issues/detail?id=10552.
On Aug 16, 3:54 pm, "thilo.haged...@googlemail.com" <thilo.haged...@googlemail.com> wrote: > For a better handling and overview in expandableLists I would like to > show only the childelements of the last selected group - the > previously expanded group should be automaticly collapsed. The > groupheader of the expanded group should be als aligned to the top of > the screen to show the user that he's in the right group and that he > can start to read the group childs from the beginning. > > This worked well with the following code until now (android 1.5 - 2.1) > but with android 2.2 the selection seems to work after the collapse > method call: > > private int currentHourPosition = -1; > private ExpandableListView expandableListView; > > @Override > public void onGroupExpand(int groupPosition) { > super.onGroupExpand(groupPosition); > if(currentHourPosition != -1 && currentHourPosition != > groupPosition){ > expandableListView.collapseGroup(currentHourPosition); > } > currentHourPosition = groupPosition; > expandableListView.setSelectedGroup(groupPosition); > } > > If a group is selected by touch and expanded it should collapse the > previously expanded group (if one exists). To align the groupheader to > the top of the screen the method "setSelectedGroup(groupPosition)" is > called. > > Without collapsing a group (e.g. if you close the group manually > before you open another) the selection is done correctly, otherwise > the list entries of the expanded group are shown somewhere in the > middle and not at the top as expected. > Has someone a solution or workaround for this issue? > The new API method smoothScrollToPosition (API level 8) is also not > working in this case. > I mentioned this issue also > here:http://code.google.com/p/android/issues/detail?id=9177 -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en