After playing with it a little bit I discovered more interesting
thing.
Frankly speaking, I used my extension of the ListView, shortly
public class MyListView
{
...
public void setSelection(long theID)
{
ListAdapter adapter = getAdapter();
if (adapter == null) {
return;
}
for (int i = 0; i < adapter.getCount(); i++) {
if (adapter.getItemId(i) == theID) {
setSelection(i);
break;
}
}
}
}
or smth like that. The problem is that after calling setSelection(int)
the selection was not changed when the list in the touch mode. I know
that setSelection should be called via post(Runnable) method, so all
setSelection(long) (me method) calls were performed via post().
Besides, in the other cases (non-touch mode, onSave/
RestoreInstanceState) this setSelection(long) worked just perfectly.
I decided to change method setSelection(long theID) like this
public void setSelection(long theID)
{
ListAdapter adapter = getAdapter();
if (adapter == null) {
return;
}
for (int i = 0; i < adapter.getCount(); i++) {
if (adapter.getItemId(i) == theID) {
final int position = i;
post(new Runnable() {
public void run()
{
setSelection(position);
}
});
break;
}
}
}
I don't know why (do I need to call post(Runnable) from another
postRunnable()?), but it seems it helped... and... it broke onSave/
RestoreInstanceState :( On the second screen rotation selected item in
the list is not restored (1 item becomes selected), when I return back
to simpler solution, onSave/Restore works fine but selection after
returning from the form doesn't work.
The only my hope is that Romain Guy can see message and explain what's
going on here.
--
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en