Closed IgordeOliveira closed 6 years ago
You can use T findViewById (int id)
and int indexOfChild (View child)
to find the position of a button:
final MultiSelectToggleGroup multi = (MultiSelectToggleGroup) findViewById(R.id.group_weekdays);
Set<Integer> checkedIds = multi.getCheckedIds();
Set<Integer> positions = new HashSet<>(); // Holder for all checked positions
for (int id : checkedIds) {
View view = multi.findViewById(id);
int position = multi.indexOfChild(view);
positions.add(position);
}
You can also add extra data like position on each button using tags, so that you can get the position from the button directly.
Works, thanks
I have a MultiSelectToggleGroup with all the days of the week as in the image, I need to check these days (if they beat the current day), but not to use the texts because it has repeated (SATURDAY and SUNDAY is "S"), how do I get the position of items checked? or another way to do it?