我正在使用滑动功能在android listview中删除。它从数据库中删除,但是当我刷新按钮时不会在列表视图中更新,它将更新,但是我想在滑动删除后迅速更新。
dbhelper.java
public void deleteInterestId(DesignItems designItems) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("delete from " + TABLE_CONTACTS + " where " + KEY_NOTIFICATION_ID + " = '" + designItems.getNotificationId() + "'");
db.close();
}
main.java
SwipeDismissListViewTouchListener touchListener =
new SwipeDismissListViewTouchListener(
notificationList,
new SwipeDismissListViewTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
return true;
}
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
final DesignItems m = designItemsList.get(position);
DesignItems designItems = new DesignItems();
designItems.setNotificationId(m.getNotificationId());
dbHelper.deleteInterestId(designItems);
designItemsList.remove(position);
list_adapter.notifyDataSetChanged();
}
}
});
notificationList.setOnTouchListener(touchListener);
因此欢迎最优秀的解决方案。