quest
quest

Reputation: 457

Disable click of a child layout in list item

In a list item, I have two view groups with id's as above and below layouts. When above layout is swiped below layout will be visible. Now, when I click on the below layout I don't want click event to happen. It shouldn't highlight the view.

Below is the layout code,

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout   
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants"> 

     <!-- need to disable click event for this layout-->
     <RelativeLayout                   
        android:id="@+id/below
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:visibility="gone"
        >

        <include layout="@layout/options" />
    </RelativeLayout>

    <LinearLayout
        android:id="@+id/above"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >


            <TextView
                android:id="@+id/view”
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/content” />


    </LinearLayout>

Upvotes: 0

Views: 1191

Answers (2)

Paulo
Paulo

Reputation: 3008

I think that you can solve this problem by setting an empty onTouch for this layout.

RelativeLayout rl = (RelativeLayout) findViewById(R.id.below);
rl.setOnTouchListener( new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return true;
    }
});

Upvotes: 1

Toukea Tatsi
Toukea Tatsi

Reputation: 199

i am not sure to understand what you realy want; but a thig that, you have juste to set attributes android:focusable="false" android:focusableInTouchMode="false" to the view you don't want to be selected

Upvotes: 0

Related Questions