I have ScroolView and it’s inside Linear layout. In this linear layout i added programmically around 20 TextView. When i press any of those TextView i change it color to RED (at first it was white). When i press again the same TextView i check his color and if it’s is RED i again make it white.
What i want to do:
I press for example 1 TextView and make it RED. Then when i press 2 TextView i make this one RED and i want to make 1 TextView WHITE. This functionality should be at all TextView.
So any idea’s how to do this ?
You mean to say at a time you need only one textview to be red. You can do this using 2 variables. One is a boolean
colored. This indicates that at least one TextView is colored. Another is a TextView variable. Create a TextView variablelastColoredTextView. Let it be null initially. Then whenever the textview is clicked, assign thelastColoredTextViewto the clicked TextView. Then whenever you are clicking, just check ifcoloredthen change the color oflastColoredTextViewto white.