2014-04-25 3 views
0

스 와이프를 구현하여 앱에 기능을 해제하려고합니다. 내부에 TableRowout이 포함되어 있으며 각 테이블 행에 TextView와 EditText가 있습니다.스 와이프하여 테이블 행이 작동하지 않음

<TableLayout 
    android:id="@+id/tableLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TableRow 
     android:id="@+id/tableRow" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/textView" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:layout_weight="2"/> 

     <EditText 
      android:id="@+id/editText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:ems="7" 
      android:layout_weight="1" 
      android:selectAllOnFocus="true" 
      android:inputType="numberDecimal"/> 
    </TableRow> 
</TableLayout> 

다음과 같이 this SwipeDismissTouchListener.java 클래스를 내 앱에 추가하고 이것을 onActivityCreated() 메소드 내부의 Activity 코드에 추가했습니다.

 tableRow.setOnTouchListener(new SwipeDismissTouchListener(
         tableRow, 
         null, 
         new SwipeDismissTouchListener.DismissCallbacks() { 
          @Override 
          public boolean canDismiss(Object token) { 
           return true; 
          } 

          @Override 
          public void onDismiss(View view, Object token) { 
           tableLayout.removeView(tableRow); 
          } 
         })); 

하지만 테이블을 스 와이프하면 아무 일도 일어나지 않습니다. 문제는 무엇인가요?

답변

1

보기에는 onClickListener을 구현해야합니다. 그렇다면 SwipeDismissTouchListener 만 작동하는 것 같습니다.

this을 참조하십시오. 나머지 코드는 괜찮아 보입니다.

희망이 도움이됩니다.

+0

예, 작동 중입니다. 많이 sooo 감사합니다! – Annoynymoousrsa

+0

@SniperDW 기꺼이 도와 드릴 수 있습니다 :) –

0
tableRow.setOnTouchListener(new SwipeDismissTouchListener(
         tableRow, 
         null, 
         new SwipeDismissTouchListener.DismissCallbacks() { 
          @Override 
          public boolean canDismiss(Object token) { 
           return true; 
          } 

          @Override 
          public void onDismiss(View view, Object token) { 
           tableLayout.removeView(view); 
          } 
         })); 
관련 문제