public MenuItem setChecked(boolean checked) {
    if ((mFlags & EXCLUSIVE) != 0) {
      // Call the method on the Menu since it knows about the others in this
      // exclusive checkable group
      mMenu.setExclusiveItemChecked(this);
    } else {
      setCheckedInt(checked);
    }

    return this;
  }
Beispiel #2
0
  void setExclusiveItemChecked(MenuItem item) {
    final int group = item.getGroupId();

    final int N = mItems.size();
    for (int i = 0; i < N; i++) {
      MenuItemImpl curItem = mItems.get(i);
      if (curItem.getGroupId() == group) {
        if (!curItem.isExclusiveCheckable()) continue;
        if (!curItem.isCheckable()) continue;

        // Check the item meant to be checked, uncheck the others (that are in the group)
        curItem.setCheckedInt(curItem == item);
      }
    }
  }