Created
May 20, 2020 05:54
-
-
Save chelseatroy/aeea621dbc19f6b1fa742ff50c35e1ff to your computer and use it in GitHub Desktop.
Exclusive Selection View Collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
var moods = arrayListOf<String>( | |
"UNSELECTED", | |
"UNSELECTED", | |
"UNSELECTED", | |
"UNSELECTED", | |
"UNSELECTED" | |
) | |
for ((index, button) in moodButtonCollection.withIndex()) { | |
val thisButtonIndex = index | |
button?.setOnClickListener({ view -> | |
for ((index, button) in moodButtonCollection.withIndex()) { | |
moods.set(thisButtonIndex, "SELECTED") | |
view.setBackgroundColor(selectedColor); | |
currentMood = Mood.values()[thisButtonIndex] | |
if (moods.get(index) == "SELECTED" && index != thisButtonIndex) { | |
moods.set(index, "UNSELECTED") | |
button?.setBackgroundColor(unselectedColor) | |
} | |
}; | |
}) | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment