How does Linear Layout get focus?

I am developing an Android application.
I was created by an activity that contains several components
upstairs contains a spinner,

after that it contains a linear layout in which it has two text fields,
1 has a static value, and the other has a dynamic value, which is filled when the user clicks on this linear logo, a dialog box is created and after setting the value in this dialog box, it fills another text image.
I have 4 linearlayout of this type, after which I have another linear layout at the end that contains 2 buttons.

The problem is that in the emulator, when I scroll the mouse, it focuses on the counter, and after that the last button (means that the color changes to orange)

So the question is how can I focus on this 4-line layout (I set focusable and focusontouch and clickable to true for this linearlayout.)

+4
source share
3 answers

I did this, and setting android:clickable="true" on my LinearLayout did the trick. I just set the click handler for this layout when I set up my views.

+4
source

Try setting android:focusable=true ,

I am not sure about this, but I can solve your problem.

+1
source

I have a LinearLayout with:

  <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/selectorbarbutton" android:clickable="true" android:focusable="true" android:orientation="vertical" > 

and this work allows you to get focus and click events correctly.

+1
source

All Articles