From 6691fcfbc806ecfd884ab2e5ff75994d7ee3ddd5 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Wed, 14 Apr 2010 14:43:18 -0700 Subject: [PATCH] Ensure Gallery does not unselect the selected item after a layout. Bug #2573921 Change-Id: I5c39881f541835fe5515b35a9f12761a8a2c1b8b --- core/java/android/widget/Gallery.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java index f34823cb484a3..6775a9497a5f4 100644 --- a/core/java/android/widget/Gallery.java +++ b/core/java/android/widget/Gallery.java @@ -1207,7 +1207,7 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList // We unfocus the old child down here so the above hasFocus check // returns true - if (oldSelectedChild != null) { + if (oldSelectedChild != null && oldSelectedChild != child) { // Make sure its drawable state doesn't contain 'selected' oldSelectedChild.setSelected(false); @@ -1263,6 +1263,7 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList */ if (gainFocus && mSelectedChild != null) { mSelectedChild.requestFocus(direction); + mSelectedChild.setSelected(true); } }