Delete all list items which are checked
I have a ListActivity binding to a database with a Custom SimpleCursorAdapter. in each of my list items I have 4 texts, image and checkbox (each one is set to focusable:false).
In the list itself I have a long button so when I press on it, I want it to delete all the rows which thire checkboxes are 'checked'.
Now, I have tried many techniques in order to achieve a simple oper开发者_如何转开发ation (click listeners, CheckedtextView as shown in the tutorial) but was not successful.
There is also another weird phenomenon occurring, after I @Override onListItemClick, also i dont get any calls at all while I am pressing on any of the list's rows.
Does anybody have any idea how to solve these issues? Thanks.
Thanks,
Moshic.
Are you calling super.onListItemClick(ListView, View, int, long);
? if so, try write out a Log.d("ListView", "My list has been clicked");
and see if that comes out in the Logcat. If it doesn't, try extends ListActivity
in your activity declaration. comment back if you want my help, I'll be ready to help as much as possible
create your own adapter with following features
-in getView() you have to set click listener for check box(it will be own listener for each check box)
-each element of adapter contains flag checked/unchecked, and you should set it by check box click listener from previous point
- in activity with delete button click listener you have to get checked elements from adapter and do with them what you want
- after then you should update list view for example by calling (your adapter).notifyDataSetChanged()
精彩评论