开发者

how to delete a row of Listview on unchecking the checkbox?

I am having listview in my applic开发者_C百科ation which contain textview and checkbox.I want to delete the entire row on deselecting the chechkbox. I am using the simple cursor adapter to populate the listview.


I think you'd have to use a custom adapter (override getView method on adapter) and hook up an event to the checkbox when clicked to delete the row from the adapter:

 final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
checkbox.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
        // Perform action on clicks, depending on whether it's now checked
        if (((CheckBox) v).isChecked()) {
            // delete row
        } 
    }
});

There are loads of examples of using a custom adapter.


see this thread it must help you. here it is implemented for click event of button same thing you can do it for checkbox. you must be facing problem in getting row id of row

add comment for any doubt

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜