Merge "Fix bug 5514022 - ListView should not auto-scroll selected item to top when gaining focus" into ics-mr1
This commit is contained in:
@@ -3361,6 +3361,7 @@ public class ListView extends AbsListView {
|
||||
|
||||
final ListAdapter adapter = mAdapter;
|
||||
int closetChildIndex = -1;
|
||||
int closestChildTop = 0;
|
||||
if (adapter != null && gainFocus && previouslyFocusedRect != null) {
|
||||
previouslyFocusedRect.offset(mScrollX, mScrollY);
|
||||
|
||||
@@ -3392,12 +3393,13 @@ public class ListView extends AbsListView {
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
closetChildIndex = i;
|
||||
closestChildTop = other.getTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closetChildIndex >= 0) {
|
||||
setSelection(closetChildIndex + mFirstPosition);
|
||||
setSelectionFromTop(closetChildIndex + mFirstPosition, closestChildTop);
|
||||
} else {
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user