views:

38

answers:

0

Hi all!

I have a basic LinerLayout with a TextView and an ImageView I would like to do the same thing as with a button: when you click on this linear layout, the background changes. I can change the background when I focus the LinearLayout (with the trackball), but I can't when I click on it! And I don't know why. I tried a lot of things, in vain! Any idea? Thanks by advance

My Linear Layout:

<LinearLayout
        android:orientation="horizontal"
        android:id="@+id/widgetProvider"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:focusableInTouchMode="true"
        android:clickable="true"
        android:layout_margin="1dip"
        android:background="@drawable/textview">

        <ImageView
            android:id="@+id/imgProvider"
            android:layout_width="60dip"
            android:layout_height="fill_parent"
            android:layout_marginRight="5dip"
            android:src="@drawable/icon" />

        <TextView android:id="@+id/txtProvider" 
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" 
                android:maxHeight="10dip"
                android:text="@string/provider"
                android:gravity="center_vertical">
            </TextView>

    </LinearLayout>

My changing background (textview.xml)

<selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;

<item android:state_pressed="true" android:drawable="@drawable/tabbar_background" />    

<item android:state_focused="true" android:drawable="@drawable/tabbar_background" />
<item android:drawable="@drawable/white"/>