我試圖實現滑動將其關閉功能,以我的應用程序錶行,我有一個TableLayout與一羣裏面TableRows的,每個錶行都有一個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類添加到我的應用程序中,並將其添加到我的Activity的onActivityCreated()方法內的代碼中。
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);
}
}));
但是,當我滑動tableRow,什麼都沒有發生,似乎是什麼問題?
是的,它現在工作!謝謝sooo多! – Annoynymoousrsa
@SniperDW很高興我能幫忙:) –