You need to keep a list / reference to the items as they are added to the adapter. This is something I created for a similar library:
participantsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Timber.d("Item clicked position is: " +position);
ParticipantChipInput selectedChip =
participantChipListAdapter.getParticipantChipInputs().get(position);
selectedChip.setSelected(!selectedChip.isSelected());
if (selectedChip.isSelected()) {
participantChipsList.addChip(selectedChip);
} else {
participantChipsList.removeChip(selectedChip);
}
participantChipListAdapter.notifyDataSetChanged();
}
});