I have a listview where the items there is generated by phpmysql, my listview has a name and a checkbox now what i want to do is when i check some items in the listview it will send the checked items in another table in my database in a click of a button. How can i do that? I don't have any code for checkbox because i dont know where to put it. Thanks!
private void getSelectedItems() {
List<String>list = new ArrayList<String>();
try {
SparseBooleanArray checkedItems = new SparseBooleanArray();
checkedItems = listView.getCheckedItemPositions();
if (checkedItems == null) {
return;
}
final int checkedItemsCount = checkedItems.size();
for (int i = 0; i < checkedItemsCount; ++i) {
int position = checkedItems.keyAt(i);
boolean bool = checkedItems.valueAt(position);
if (bool) {
list.add(mainList.get(position));
}
}
} catch (Exception e) {
}
}
Aucun commentaire:
Enregistrer un commentaire