Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created May 20, 2020 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/ef80d5fbc8376caadff61f7e246c080e to your computer and use it in GitHub Desktop.
Save chelseatroy/ef80d5fbc8376caadff61f7e246c080e to your computer and use it in GitHub Desktop.
Exclusive Selection Less Code
...
for ((index, button) in moodButtonCollection.withIndex()) {
button?.setOnClickListener({ view ->
for (button in moodButtonCollection) button?.setBackgroundColor(unselectedColor);
view.setBackgroundColor(selectedColor);
currentMood = Mood.values()[index]
})
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment