Android ListView之选中(撤销选中)Item

在ContactListActivity中,点击未选中的item将其选中,再点击已选中的item撤销其选中

public void onItemClick(AdapterView<?> parent, View view, int position,
        long id) {
    ContactListAdapter.ViewHolder viewHolder = null;
    if(mListAdapter.bShowCheckBox) {
        viewHolder = (ContactListAdapter.ViewHolder)view.getTag();
        TxrjContact contact = (TxrjContact)mListAdapter.getItem(position);
        contact.setSelected(!contact.isSelected());
        viewHolder.select
                .setImageBitmap(contact.isSelected() ? mListAdapter.checkBox
                        : mListAdapter.unCheckBox);
    }
}

你可能感兴趣的:(Android ListView之选中(撤销选中)Item)