Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Linear Layout get Focus?

I am developing an android application.
I was created an activty that contains several components
on the top it contains spinner,

after that it contains linear layout in which it has two textview,
1 has static value and other is dynamic value that is filled when user click on that linear loyout an dialogbox is created and after setting value on that dialog it fills other textview.
i have 4 linearlayout of this type after that i have another linear layout at the end that contains 2 button.

The problem is that in emulator when i scroll mouse it focus on the spinner and after that the last button(means it color changes to orange)

So the question is that how can i get focus on that 4 linear layout?(i set focusable & focusontouch & clickable value true of that linearlayout.)

like image 608
Anant Avatar asked Sep 20 '11 05:09

Anant


2 Answers

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

like image 170
Sky Kelsey Avatar answered Sep 21 '22 13:09

Sky Kelsey


From @david-lord's comment, only the parameter

focusableInTouchMode="true"

is necessary, so in XML

<LinearLayout
    android:id="@+id/linear_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:focusableInTouchMode="true">

allows the call

linear_layout.requestFocus()
like image 36
fireb86 Avatar answered Sep 20 '22 13:09

fireb86