I performed the same task in one of my applications.
What you need to do is use an ArrayList with the same size as the list item, and each item contains a default. Now in your efficient adapter, for each checkbox set, assign 1 at this specific position to arrayList. Finally, by clicking the "Delete" button, go through ArrayList and remove all of these elements from the list that contain 1 in this entry in this ArrayList and atLast call the notifyDatasetChanged () method of the list to update the list and show the new list.
Here is a sample code to help you better understand:
ArrayList<Integer> checks=new ArrayList<Integer>();
Now in the onCreate method
for(int b=0;b<tempTitle.length;b++){ checks.add(b,0); //assign 0 by default in each position of ArrayList }
Now in your efficient getView method
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.bookmarks_list_item, null); holder = new ViewHolder(); holder.text1 = (TextView) convertView .findViewById(R.id.title); holder.text2 = (TextView) convertView .findViewById(R.id.body); holder.checkBox = (CheckBox) convertView.findViewById(R.id.checkbox); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.checkBox.setOnClickListener(new OnClickListener() { public void onClick(View v) {
Finally, click the "Delete" button:
delete.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub for(int i=0;i<checks.size();i++){ if(checks.get(i)==1){ //remove items from the list here for example from ArryList checks.remove(i); //similarly remove other items from the list from that particular postion i--; } } ((EfficientAdapter)lv.getAdapter()).notifyDataSetChanged(); } }
Hope this solves your problem.
source share