Created
June 19, 2012 01:21
-
-
Save pboos/2951782 to your computer and use it in GitHub Desktop.
selectable adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Set<String> mSelectedContactNumbers = new HashSet<String>(); | |
@Override | |
public void bindView(View view, Context context, final Cursor cursor) | |
{ | |
final String contactNumber = cursor.getString(cursor.getColumnIndex("contact_number")); | |
view.setOnClickListener(new View.OnClickListener() | |
{ | |
@Override | |
public void onClick(View v) | |
{ | |
if (!mSelectedContactNumbers.remove(contactNumber)) { | |
mSelectedContactNumbers.add(contactNumber); | |
} | |
notifyDataSetChanged(); | |
} | |
}); | |
if (mSelectedContactNumbers.contains(contactNumber)) { | |
view.setBackgroundColor(0xff333333); | |
} else { | |
view.setBackgroundColor(0); | |
} | |
createView(view, cursor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment