Z
Z
ZAndrew2015-08-21 10:19:44
Android
ZAndrew, 2015-08-21 10:19:44

How to programmatically switch clickable focus from a TextView to its containing LinearLayout?

Faced such problem: There is TextView in LinearLayout. When you click on the TextView , the OnClickListener of this element fires, and the OnClickListener of the LinearLayout itself, accordingly, does not fire. How to achieve that, depending on a certain parameter set / reset by pressing an additional button, the OnClickListener of either the layer or the TextView would work.

LinearLayout{
     TextView
}
ДругойLayout{
    Button 
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LeEnot, 2015-08-21
@LeEnot

You need to make your LinearLayout clickable:
yourLinearLayout.setClickable(true);

A
Alexey Perelygin, 2015-08-22
@orcDamnar

If you need to override the standard behavior of the system - the best option would be to override the reaction to the parent for the parent - in the above case, this is LinearLayout. extend the LinearLayout class and define onInterceptTouchEvent, onTouchEvent and dispatchTouchEvent in it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question