0

I am working with a custom adapter, having ListItems with CheckBoxes.
While I select multiple checked items and try to remove them, only the first item gets removed...

How could I remove all the selected items?

Here is my code:

button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub


               for(int i= 0; i < listdp.size();i++)
               {



               if(adapterfirst.mCheckStates.get(i) == true)
                {
                    listdp.remove(i);


                                   }
                                 }
 adapterfirst.notifyDataSetChanged();
        }

    });

Could somebody help me showing me how could I delete the selected items in listview?

Thanks

1 Answers1

0

you can try your calling adapterfirst.notifyDataSetChanged(); after your for loop which remove all selected values .

Hardik
  • 94
  • 1
  • 1
  • 11
  • thanks but if i use listdp.remove(adapterfirst.mCheckStates.get(i)); i can't able to delete any data,but if i use listdp.remove(i); on selcting multiple items..while delete the first item is getting deleted. –  Feb 10 '14 at 08:43
  • 1
    you can refer this link http://stackoverflow.com/questions/18715556/removing-muliple-items-from-listview-using-check-box-in-android – Hardik Feb 10 '14 at 16:51
  • also refer this link http://stackoverflow.com/questions/16009209/delete-multiple-items-in-custom-listview – Hardik Feb 10 '14 at 16:52