开发者

change background color of 2 textviews, every 2nd click (like in table tennis)

开发者 https://www.devze.com 2023-03-05 21:20 出处:网络
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).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消