Android - 如何检测特定视图上的手势?

Android - how to detect gesture on a specific View?

如何在不同的视图中检测手势(右手势或左手势)?

我有两个 LinearLayout ,我想在其中一个上检测手势

main.xml 是:

    <LinearLayout
        android:id="@+id/lllcd"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="0.30"
        android:orientation="vertical" android:background="@drawable/header" android:layout_margin="1dip">
        <TextView
            android:id="@+id/txtlcdmini"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="0.3"
            android:gravity="right|center"
            android:textColor="#ff0000"
            android:textSize="15dip" android:typeface="normal"/>
        <TextView
            android:id="@+id/txtlcdresult"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="0.7"
            android:gravity="right|center"
            android:text="0"
            android:textColor="#000000"
            android:textSize="35dip"/>

    </LinearLayout>
   <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="0.70"
        android:orientation="vertical" android:layout_marginTop="0dip" android:layout_marginLeft="8dip" android:layout_marginRight="8dip" android:layout_marginBottom="2dip">

    </LinearLayout>

http://developer.android.com/training/gestures/index.html

yourView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                ...your code
            }
        });