OSDN Git Service

AbsListView does not populate accessibility events correctly.
authorSvetoslav Ganov <svetoslavganov@google.com>
Mon, 5 Sep 2011 23:41:47 +0000 (16:41 -0700)
committerSvetoslav Ganov <svetoslavganov@google.com>
Mon, 5 Sep 2011 23:41:51 +0000 (16:41 -0700)
The toIndex of accessibility events fired from a AbsListView
is exclusive but should be inclusive i.e. it was reported one
more that it has to be.

bug:5256286

Change-Id: I496959fdfb6760b0c74899730c4cc558e89234a6

core/java/android/widget/AdapterView.java

index 4ba604d..b945038 100644 (file)
@@ -926,8 +926,10 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
         }
         event.setItemCount(getCount());
         event.setCurrentItemIndex(getSelectedItemPosition());
-        event.setFromIndex(mFirstPosition);
-        event.setToIndex(mFirstPosition + getChildCount());
+        if (getChildCount() > 0) {
+            event.setFromIndex(getFirstVisiblePosition());
+            event.setToIndex(getLastVisiblePosition());
+        }
     }
 
     @Override