2010-11-20 4 views
1

친애하는 Android 해커들, ListView에 flings을 인식하는 gestureListener를 추가하려고합니다. ListView의 행은 LinearView와 일부 TextView로 구성됩니다. 그것은 TextViews 중 하나를 시작하면 불행하게도, 별거가 감지되지 : 나는 수평있는 LinearLayout에 별거를 시작할 때 나는에있는 텍스트 뷰에 시작할 때, 모든 것이 잘 작동하지만 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> 

바닥, 아무 일도 일어나지 않습니다. 그것은 문제가 될 수있는 경우 편집 가능한 텍스트를 포함합니다 ... 리스너는 ListView 자체에 첨부됩니다.

누군가가 도울 수 있다면 기쁠 것입니다.

월 올리버

답변

3

수정 가능한 텍스트 뷰는 LinearLayout까지 높은 뷰 계층에 의해 처리되는 경우를 방지 onTouch()true에서 반환된다.

사용자 정의 OnTouchListenerTextView에 첨부하는 것을 막을 수있는 방법은 없습니다.이를 무시하고 기존 GestureDetector에 이벤트를 전달하십시오.

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

감사합니다. 나는 이틀 후에 이것을 시도 할 것이다. – janoliver

+0

작동. 고마워요! – janoliver

관련 문제