我有一个带有自定义数组适配器的listview。 对于我的listview,我设置了longitemclick进行删除。 长按我用删除命令显示动作菜单如下:
if(item.getItemId() == R.id.action_delete)
{
SparseBooleanArray selected = teamarrayadapter.getSelectedIds();
short size = (short)selected.size();
boolean number = mHelper.deleteTeam(new_id);
for (byte I = 0; I<size; I++){
if (selected.valueAt(I)) {
String selectedItem = teamarrayadapter.getItem(selected.keyAt(I));
teamarrayadapter.remove(selectedItem);
}
}
// Close CAB (Contextual Action Bar)
mode.finish();
return true;
}
return false;
但它只删除列表项而不删除我用
删除的数据项public boolean deleteTeam (int teamId){
SQLiteDatabase db = this.getWritableDatabase();
return db.delete("teams", "teams_id = ? ", new String[]{Integer.toString(teamId)})>0;
}
我该如何解决这个问题?