1. I took the advice of others on this list and changed my drawing
code so that if the number of items in the ListView has not changed,
instead of calling ArrayAdapter.notifyDataSetChanged(), I instead
iterate over the ListView visible children and attempt to update them
manually.


                int firstVisibleDataSetPosition =
listView.getFirstVisiblePosition();
                for(int dataSetPosition = firstVisibleDataSetPosition;
dataSetPosition <=  listView.getLastVisiblePosition(); dataSetPosition+
+) {
                    View view =  listView.getChildAt(dataSetPosition -
firstVisibleDataSetPosition);
                    updateView(view, dataSetPosition);
                }


2. In certain cases, my data set holds one object.  Sometimes when
this happens, listView.getFirstVisiblePosition is returning "1", when
instead it should return 0, because the data set has only one object.
If I then attempt to retrieve the data item at index 1 using
ArrayAdapter.getItem(), I get an IndexOutOfBoundsException.

It seems to me getFirstVisiblePosition() cannot be used reliably if it
stands the chance of returning an invalid value.  Is this variable not
updated in certain cases, where it can get out of sync with the data
set?

- Eric

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

Reply via email to