I have a CheckedTextView which allows the user to check multiple items. I want the user to only select up to 10 items and then prevent them from checking any more items once 10 has been reached. The problem is that im not able to uncheck the 11th item once its been selected. Ive tried TextView.setChecked(false) but nothing seems to happen. Is there a way to get this to work? or a better way of going about it? Here is part of my code
@Override protected void onListItemClick (ListView l, View v, int position, long id){
CheckedTextView TextView = (CheckedTextView) v;
TextView.setChecked(false);
if(Image_Count>=1){
if (TextView.isChecked()) {
mDbHelper.UpdatePostImage(id, "");
Image_Count =Image_Count +1;
}
else if (!TextView.isChecked()) {
mDbHelper.UpdatePostImage(id, PostID);
Image_Count = Image_Count -1;
}
Toast.makeText(getBaseContext(),"Add up to " + String.valueOf(Image_Count)+" more photos", Toast.LENGTH_SHORT).show();
}else{
TextView.setChecked(false);
Toast.makeText(getBaseContext(),"only 10 maximum photos allowed", Toast.LENGTH_SHORT).show();}
}
}