I created a Gridview with CHOICE_MODE_MULTIPLE_MODAL in Android.
Everything\'s working well. But as per requirements, I have to set a limit for selecta
In order to deselect the current item in a multiple Choice gridview, you can use the following in the onItemCheckedStateChanged()
of the GridView.MultiChoiceModeListener
:
@Override
public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean checked) {
if(gridView.getCheckedItemCount() > numberOfSelectionsAllowed ){
gridView.setItemChecked(position, false);
}
}