I have a ViewGroup
that can have many LinearLayout
s. And each LinearLayout
can have many nested child views. What I want is that, if any view(even deep nested) inside a LinearLayout
gets focus, it should call a custom method of its main parent LinearLayout
.
The last thing I want to do is, set OnFocusChangeListener
on every single deep nested child views of LinearLayout
and that listener will call its parent's custom method. But that is really bad way to go for.
Is there any method I can override of parent LinearLayout
that gets called every time its any nested child view's focus changes ?
You could use contentView.getViewTreeObserver().addOnGlobalFocusChangeListener()
or override ViewGroup.requestChildFocus()
of the root ViewGroup (requestChildFocus()
is passed along the view parent chain).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With