Pregunta

In my app I dynamically create a list of buttons. The user should be able to click on them. A short click would select the buttom as the current item, while a long click should enter the editor for this item.

Now I wonder how I can determine and set the colors that i should use. My first idea was to simply read the background and textcolor and switch them, however I'm not sure if this would be really the appropriate way to do this. So I was wondering if there is a an appropriate way of how to retrieve colors.

Of course I could hardcode some colors, but I don't know what color scheme the user has set and they might not be visible in a good way.

Please note, that, since I have to create the buttons dynamically, I can not set it in the XML.

¿Fue útil?

Solución

You could simply use a ToggleButton, so android will take care of marking a "clicked" button as selected.

Since ToggleButton is a View, it has a setOnLongClickListener(Listener)-method, which can be used to make the ToggleButton long-clickable.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top