アンドロイド:複雑な行でリストビュー上での検出を投げつけます

StackOverflow https://stackoverflow.com/questions/4235577

質問

親愛なるAndroidのハッカー、私は、ListViewコントロールに投げつけるを認識gestureListenerを添付しています。リストビューの列はLinearViewといくつかのTextViewsで構成されています。それは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>
だから、私は水平方向のLinearLayoutに情事を開始すると、すべてが正常に動作しますが、私は一番下にあるのTextView上で起動した場合、何も起こりません。それが問題になる可能性がある場合には、編集可能なテキストをcontaints ...としては、リスナーがListViewコントロール自体に添付された、と言われています。

誰かが助けることができれば、私は喜んでいると思います!

ヤン・オリバー

役に立ちましたか?

解決

あなたの編集可能な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