Reputation: 12444
If i had Button btn1
and i had another Button btn2
how to connect the two views on the same events like onPress, onFocus.
let me explain:
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.
any ideas?
Upvotes: 0
Views: 4044
Reputation: 15
If You don't want the click event to be passed to btn2, do a btn2.callOnClick
instead. It will call any onClick
action listener associated with btn2
. If there aren't any, it'll return false.
Upvotes: 0
Reputation: 12375
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
Upvotes: 4
Reputation: 20356
Call manually performClick()
(or similar method) of btn2
in the onPress()
or onFocus()
listeners of btn1
.
Upvotes: 0