سؤال

عزيزي Android Hackers ، أنا أرفق gesturelistener يتعرف على Flings بمشاهدة ListView. تتكون صفوف ListView من LinearView وبعض LextViews. لسوء الحظ ، لم يتم الكشف عن التقليب ، عندما يبدأ على أحد رؤوس النص:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#000000" >
        <TextView
            android:id="@+id/author"
            android:textSize="14sp"
            android:textColor="#ffffff"
            android:textStyle="bold"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"/>
        <TextView
            android:id="@+id/date"
            android:textSize="11sp"
            android:textColor="#eeeeee"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"/>
    </LinearLayout>
    <TextView
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="5dp"
        android:paddingRight="5dp"
        android:paddingLeft="5dp"
        android:textColor="#333333"

        android:paddingBottom="5dp"
        android:textSize="14sp"
        android:layout_weight="2"/>
</LinearLayout>

لذلك ، عندما أبدأ الافتراض على LinearLayout الأفقي ، كل شيء يعمل بشكل جيد ، ولكن عندما أبدأ على TextView في الأسفل ، لا شيء يحدث. إنه يحتوي على نص قابل للتحرير ، إذا كان ذلك قد يكون المشكلة ... كما يقال ، يتم إرفاق المستمع بمشاهدة القائمة نفسها.

سأكون سعيدًا إذا كان شخص ما يمكن أن يساعد!

جان أوليفر

هل كانت مفيدة؟

المحلول

TextView القابل للتحرير الخاص بك يعود true من عند onTouch(), ، منع الحدث من معالجته بواسطة LinearLayout أعلى أعلى عرض التسلسل الهرمي.

لا يوجد شيء يمنعك من إرفاق العرف OnTouchListener لك TextView لتجاوز هذا وتمرير الحدث إلى موجودك GestureDetector.

textView.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View arg0, MotionEvent ev) {             
        return gestureDetector.onTouchEvent(ev);
    }           
};
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top