i want to change the background color of 2 textviews, every 开发者_开发问答2nd click, because i'm making a scoreboard and want to change the player service every 2 points (like in table tennis).
how do you do this in the activity?
Use a boolean as a flag and swap it between true and false. Alternatively, if the total number of clicks is useful to you, you can use an incremented integer to keep track of them, and check it like if (iCount%2 == 0)
(matches 0,2,4,6 etc.)
Also, you can set the background color with something like this
textView.setBackgroundColor(0xfff00000)
or like this
textView.setBackgroundResource(R.color.red);
if you have a color.xml file set up with colours in it.
精彩评论