0

Hopefully my question is self explanatory; if not here is what I'm trying to do. I have a spinner that has 5 options. If the user selected options 1-4 I want the text in the spinner to display "Level 1" instead of the actual value that was selected.

example~

red is selected -> spinner displays "Level one"

green is selected -> spinner displays "Level one"

blue is selected -> spinner displays "Level one"

yellow is selected -> spinner displays "Level one"

Level Not Reached is selected ->spinner displays "Level Not Reached"

Is this possible? If so how should I be doing this?

Noob
  • 145
  • 2
  • 9

2 Answers2

1

Yes, you can create a new class with color and level as its properties.

After that, create a custom adapter for your spinner and call getLevel (the getter) to display the level but use getColor to get the value.

Blaze Tama
  • 10,828
  • 13
  • 69
  • 129
  • Thank you. That sounds like a good idea. However I found a solution that goes a different direction. I will post what I did as a separate answer. – Noob Nov 15 '14 at 03:30
0

I found a post that helped a lot with this question: How to hide one item in an Android Spinner.

I decided that a decent way to do it was to hide the "Level one" in the list. That way a user could not select it but I could set it as the current selection when a user selected a color.

This may not be the most elegant solution but it did work for what I needed

Community
  • 1
  • 1
Noob
  • 145
  • 2
  • 9