First take a list ArrayList<ContactDetails> checkedList
as gloabl and initialize it in consstructor..
Write a method like below in your Custom Adapter
private ArrayList<ContactDetails> getCheckedItems() {
return checkedList;
}
and change your checkbox change listener like this..
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
checkedList.add(list.get(position));
}else {
checkedList.remove(list.get(position));
}
}
});
And call adapter.getCheckedItems();
in your onItemClickListener
of your Activity
then you will get the all the checked items..