2010-11-20 6 views
1

親愛なるAndroidハッカー、ListViewにflingsを認識するgestureListenerを付けています。 ListViewの行は、LinearViewといくつかのTextViewで構成されています。だから、Android:複雑な行を持つListViewのfling検出

<?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上で起動した場合、:それはTextViewsのいずれかで開始したときに残念なことに、情事は、検出されません底は、何も起こらない。これは、問題の可能性がある場合、編集可能なテキストを含みます。リスナーは、ListView自体にアタッチされています。

誰かが助けてくれたら嬉しいです!

月オリバー

答えて

3

あなたの編集可能なTextViewには、ビュー階層までLinearLayout上位で処理されてからイベントを防止、onTouch()からtrueを返しています。

あなたはこれを上書きし、既存のGestureDetectorにイベントを渡すためにあなたのTextViewにカスタムOnTouchListenerを取り付ける止めるものは何もありません。

textView.setOnTouchListener(new OnTouchListener() { 
    public boolean onTouch(View arg0, MotionEvent ev) {    
     return gestureDetector.onTouchEvent(ev); 
    }   
}; 
+0

ありがとうございます。私は数日後にこれを試してみます。 – janoliver

+0

作品。どうもありがとう! – janoliver

関連する問題