如何更改视图时,另一种观点是pssed $ P $ /点击的 [英] How to change a view when another view is pressed/clicked
问题描述
如果我有按钮BTN1
和我有另一个按钮BTN2
如何在同一事件的两个视图连接像preSS,聚焦状态。
If i had Button btn1
and i had another Button btn2
how to connect the two views on the same events like onPress, onFocus.
让我解释一下:
当我preSS BTN1
现在 BTN1
是pressed和橙色背景的彩色
而上午pressing它,我想改变 BTN2
状态为pressed和背景颜色为橙色。
when i press btn1
now the btn1
is pressed and colored with orange background
while am pressing it, i wanna change btn2
state to be pressed and with background color orange.
什么想法?
推荐答案
您可以设置为Button1触摸监听器,你可以叫 Button2.set pressed(真)
后检查事件的作用。也就是说,如果你希望它是唯一pssed $ P $,而Button1的是pssed你会调用该函数时的行动是 ACTION_DOWN
并且当虚假的参数再次调用它$ P $行动是 ACTION_UP
。如果你想按钮2保持pressed可以使用onClicklistener而不是
You can set a touch listener for Button1 where you can call Button2.setPressed(true)
after checking the action of the event . i.e if you want it to be pressed only while Button1 is pressed you would call the function when Action is ACTION_DOWN
and call it again with a false parameter when the Action is ACTION_UP
. If you want button2 to remain pressed you can use the onClicklistener instead
这篇关于如何更改视图时,另一种观点是pssed $ P $ /点击的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!