开发者

Delete all list items which are checked

开发者 https://www.devze.com 2022-12-20 09:29 出处:网络
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).

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


  1. 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

  2. in activity with delete button click listener you have to get checked elements from adapter and do with them what you want
  3. after then you should update list view for example by calling (your adapter).notifyDataSetChanged()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号