Eu tenho dois botões: "btn1, btn2", o btn2 irá mudar aleatoriamente quando eu mudar o fundo de btn1 alpha
Eu tenho dois botões:btn1
, btn2
. Eles são usados com uma mesma imagem de fundo:pic1.png
. Quando mudei o fundo do primeiro botão:btn1
emOnTouch
evento, o código é o seguinte
onTouch_Action(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
TextView tv = (TextView) v;
int color = tv.getCurrentTextColor();
int r = (color) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 16) & 0xFF;
int a = (color >> 24) & 0xFF;
tv.setTextColor(Color.argb(50, r, g, b)); //The other uses the same background image buttons may also change
} else if (event.getAction() == MotionEvent.ACTION_UP) {
int color = tv.getCurrentTextColor();
int r = (color) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 16) & 0xFF;
int a = (color >> 24) & 0xFF;
tv.setTextColor(Color.argb(255, r, g, b)); //The other uses the same background image buttons may also change
}
}
O segundo botão:btn2
, o fundo também pode ser alterado e as alterações são aleatórias. Como evitar o segundo botão muda?