Question

Cher Android pirates, je joins un gestureListener reconnaissant flings à un ListView. Les lignes de la ListView se composent d'un LinearView et quelques TextViews. Malheureusement, le Fling n'est pas détecté, quand il commence l'un des TextViews:

<?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>

Alors, quand je commence l'aventure sur la LinearLayout horizontale, tout fonctionne très bien, mais quand je commence sur le TextView au fond, rien ne se passe. Il containts texte modifiable, si cela pourrait être le problème ... Comme on dit, le récepteur est attaché à la ListView lui-même.

Je serais heureux si quelqu'un pouvait aider!

Jan Oliver

Était-ce utile?

La solution

Votre TextView modifiable retourne true de onTouch(), ce qui empêche l'événement d'être traité par le LinearLayout plus haut dans la hiérarchie de la vue.

Il n'y a rien qui vous empêche la fixation d'un OnTouchListener personnalisé à votre TextView pour passer outre cela et passer l'événement à votre GestureDetector existant.

textView.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View arg0, MotionEvent ev) {             
        return gestureDetector.onTouchEvent(ev);
    }           
};
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top