diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/widget/AbsListView.java | 24 | ||||
-rw-r--r-- | core/java/android/widget/ListPopupWindow.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/ListView.java | 2 |
3 files changed, 26 insertions, 2 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index becda67..0966be3 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -110,6 +110,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te * @see #setTranscriptMode(int) */ public static final int TRANSCRIPT_MODE_DISABLED = 0; + /** * The list will automatically scroll to the bottom when a data set change * notification is received and only if the last item is already visible @@ -118,6 +119,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te * @see #setTranscriptMode(int) */ public static final int TRANSCRIPT_MODE_NORMAL = 1; + /** * The list will automatically scroll to the bottom, no matter what items * are currently visible. @@ -2489,8 +2491,30 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } } + /** + * Positions the selector in a way that mimics keyboard focus. If the + * selector drawable supports hotspots, this manages the focus hotspot. + */ + void positionSelectorLikeFocus(int position, View sel) { + positionSelector(position, sel); + + final Drawable selector = mSelector; + if (selector != null && selector.supportsHotspots() && position != INVALID_POSITION) { + final Rect bounds = mSelectorRect; + final float x = bounds.exactCenterX(); + final float y = bounds.exactCenterY(); + selector.setHotspot(R.attr.state_focused, x, y); + } + } + void positionSelector(int position, View sel) { if (position != INVALID_POSITION) { + if (mSelectorPosition != position) { + final Drawable selector = mSelector; + if (selector != null && selector.supportsHotspots()) { + selector.clearHotspots(); + } + } mSelectorPosition = position; } diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java index b47177a..10ec105 100644 --- a/core/java/android/widget/ListPopupWindow.java +++ b/core/java/android/widget/ListPopupWindow.java @@ -1565,7 +1565,7 @@ public class ListPopupWindow { // Ensure that keyboard focus starts from the last touched position. setSelectedPositionInt(position); - positionSelector(position, child); + positionSelectorLikeFocus(position, child); // Refresh the drawable state to reflect the new pressed state, // which will also update the selector state. diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 5de67c8..eeb8015 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -2564,7 +2564,7 @@ public class ListView extends AbsListView { if (needToRedraw) { if (selectedView != null) { - positionSelector(selectedPos, selectedView); + positionSelectorLikeFocus(selectedPos, selectedView); mSelectedTop = selectedView.getTop(); } if (!awakenScrollBars()) { |