This is part of my app screenshot.
When I click the DELETE button, I want it to delete the row of SQLite based on the ID. I tried below code but it always give me value 0.
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int itemCount = listview.getCount();
for (int i = itemCount - 1; i >= 0; i--) {
SearchList search = adapter.getItem(i);
int id = search.getID(); // get the list id from sqlite if check box is checked
if (search.isSelected()) {
adapter.removeItem(i); //remove the list item if checkbox is checked
delete.setText("DELETE");
checkBoxCounter = 0;
Toast.makeText(getApplication(),id+"",Toast.LENGTH_SHORT).show();
}
}
}
});
Aucun commentaire:
Enregistrer un commentaire