diff options
| author | 2009-06-24 15:45:03 -0700 | |
|---|---|---|
| committer | 2009-06-24 15:45:03 -0700 | |
| commit | bed64a2c4227b47a5282825f2f6827ad4a0f369c (patch) | |
| tree | 2052a338b346017f641893a624adc5ee71e58795 | |
| parent | 217b208ebd4a84b970bf8360408feaa95d5d58f1 (diff) | |
| parent | 83f6b130181982eb653621c2c4028feae36f1ffb (diff) | |
am 83f6b130: Merge change 5237 into donut
Merge commit '83f6b130181982eb653621c2c4028feae36f1ffb'
* commit '83f6b130181982eb653621c2c4028feae36f1ffb':
Calling setItemChecked(p, true) twice would toggle the selection in ListView.
| -rw-r--r-- | core/java/android/widget/ListView.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 6532125d2b0a..f8a6f89a9880 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -3264,9 +3264,13 @@ public class ListView extends AbsListView { if (mChoiceMode == CHOICE_MODE_MULTIPLE) { mCheckStates.put(position, value); } else { - boolean oldValue = mCheckStates.get(position, false); + // Clear the old value: if something was selected and value == false + // then it is unselected mCheckStates.clear(); - if (!oldValue) { + // If value == true, select the appropriate position + // this may end up selecting the value we just cleared but this way + // we don't have to first to a get(position) + if (value) { mCheckStates.put(position, true); } } |