本文整理汇总了Java中android.support.v7.view.menu.MenuItemImpl.isCheckable方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItemImpl.isCheckable方法的具体用法?Java MenuItemImpl.isCheckable怎么用?Java MenuItemImpl.isCheckable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.view.menu.MenuItemImpl
的用法示例。
在下文中一共展示了MenuItemImpl.isCheckable方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public void onClick(View v) {
NavigationMenuItemView itemView = (NavigationMenuItemView) v;
NavigationMenuPresenter.this.setUpdateSuspended(true);
MenuItemImpl item = itemView.getItemData();
boolean result = NavigationMenuPresenter.this.mMenu.performItemAction(item, NavigationMenuPresenter.this, 0);
if (item != null && item.isCheckable() && result) {
NavigationMenuPresenter.this.mAdapter.setCheckedItem(item);
}
NavigationMenuPresenter.this.setUpdateSuspended(false);
NavigationMenuPresenter.this.updateMenuView(false);
}
示例2: setCheckedItem
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public void setCheckedItem(MenuItemImpl checkedItem) {
if (this.mCheckedItem != checkedItem && checkedItem.isCheckable()) {
if (this.mCheckedItem != null) {
this.mCheckedItem.setChecked(false);
}
this.mCheckedItem = checkedItem;
checkedItem.setChecked(true);
}
}
示例3: onClick
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
DrawerNavigationMenuItemView itemView = (DrawerNavigationMenuItemView) v;
setUpdateSuspended(true);
MenuItemImpl item = itemView.getItemData();
boolean result = mMenu.performItemAction(item, DrawerNavigationMenuPresenter.this, 0);
if (item != null && item.isCheckable() && result) {
mAdapter.setCheckedItem(item);
}
setUpdateSuspended(false);
updateMenuView(false);
}
示例4: setCheckedItem
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public void setCheckedItem(MenuItemImpl checkedItem) {
if (mCheckedItem == checkedItem || !checkedItem.isCheckable()) {
return;
}
if (mCheckedItem != null) {
mCheckedItem.setChecked(false);
}
mCheckedItem = checkedItem;
checkedItem.setChecked(true);
}
示例5: onClick
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
NavigationMenuItemView itemView = (NavigationMenuItemView) v;
setUpdateSuspended(true);
MenuItemImpl item = itemView.getItemData();
boolean result = menu.performItemAction(item, NavigationMenuPresenter.this, 0);
if (item != null && item.isCheckable() && result) {
adapter.setCheckedItem(item);
}
setUpdateSuspended(false);
updateMenuView(false);
}
开发者ID:material-components,项目名称:material-components-android,代码行数:13,代码来源:NavigationMenuPresenter.java
示例6: setCheckedItem
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public void setCheckedItem(MenuItemImpl checkedItem) {
if (this.checkedItem == checkedItem || !checkedItem.isCheckable()) {
return;
}
if (this.checkedItem != null) {
this.checkedItem.setChecked(false);
}
this.checkedItem = checkedItem;
checkedItem.setChecked(true);
}
开发者ID:material-components,项目名称:material-components-android,代码行数:11,代码来源:NavigationMenuPresenter.java
示例7: onClick
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
NavigationMenuItemView itemView = (NavigationMenuItemView) v;
setUpdateSuspended(true);
MenuItemImpl item = itemView.getItemData();
boolean result = mMenu.performItemAction(item, NavigationMenuPresenter.this, 0);
if (item != null && item.isCheckable() && result) {
mAdapter.setCheckedItem(item);
}
setUpdateSuspended(false);
updateMenuView(false);
}
示例8: setCheckedItem
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
public void setCheckedItem(MenuItemImpl checkedItem) {
if (mCheckedItem == checkedItem || !checkedItem.isCheckable()) {
return;
}
if (mCheckedItem != null) {
mCheckedItem.setChecked(false);
}
mCheckedItem = checkedItem;
checkedItem.setChecked(true);
}
示例9: prepareMenuItems
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
/**
* Flattens the visible menu items of {@link #mMenu} into {@link #mItems},
* while inserting separators between items when necessary.
*/
private void prepareMenuItems() {
if (mUpdateSuspended) {
return;
}
mUpdateSuspended = true;
mItems.clear();
mItems.add(new NavigationMenuHeaderItem());
int currentGroupId = -1;
int currentGroupStart = 0;
boolean currentGroupHasIcon = false;
for (int i = 0, totalSize = mMenu.getVisibleItems().size(); i < totalSize; i++) {
MenuItemImpl item = mMenu.getVisibleItems().get(i);
if (item.isChecked()) {
setCheckedItem(item);
}
if (item.isCheckable()) {
item.setExclusiveCheckable(false);
}
if (item.hasSubMenu()) {
SubMenu subMenu = item.getSubMenu();
if (subMenu.hasVisibleItems()) {
if (i != 0) {
mItems.add(new NavigationMenuSeparatorItem(mPaddingSeparator, 0));
}
mItems.add(new NavigationMenuTextItem(item));
boolean subMenuHasIcon = false;
int subMenuStart = mItems.size();
for (int j = 0, size = subMenu.size(); j < size; j++) {
MenuItemImpl subMenuItem = (MenuItemImpl) subMenu.getItem(j);
if (subMenuItem.isVisible()) {
if (!subMenuHasIcon && subMenuItem.getIcon() != null) {
subMenuHasIcon = true;
}
if (subMenuItem.isCheckable()) {
subMenuItem.setExclusiveCheckable(false);
}
if (item.isChecked()) {
setCheckedItem(item);
}
mItems.add(new NavigationMenuTextItem(subMenuItem));
}
}
if (subMenuHasIcon) {
appendTransparentIconIfMissing(subMenuStart, mItems.size());
}
}
} else {
int groupId = item.getGroupId();
if (groupId != currentGroupId) { // first item in group
currentGroupStart = mItems.size();
currentGroupHasIcon = item.getIcon() != null;
if (i != 0) {
currentGroupStart++;
mItems.add(new NavigationMenuSeparatorItem(
mPaddingSeparator, mPaddingSeparator));
}
} else if (!currentGroupHasIcon && item.getIcon() != null) {
currentGroupHasIcon = true;
appendTransparentIconIfMissing(currentGroupStart, mItems.size());
}
if (currentGroupHasIcon && item.getIcon() == null) {
item.setIcon(android.R.color.transparent);
}
NavigationMenuTextItem textItem = new NavigationMenuTextItem(item);
textItem.needsEmptyIcon = currentGroupHasIcon;
mItems.add(textItem);
currentGroupId = groupId;
}
}
mUpdateSuspended = false;
}
示例10: prepareMenuItems
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
/**
* Flattens the visible menu items of {@link #menu} into {@link #items}, while inserting
* separators between items when necessary.
*/
private void prepareMenuItems() {
if (updateSuspended) {
return;
}
updateSuspended = true;
items.clear();
items.add(new NavigationMenuHeaderItem());
int currentGroupId = -1;
int currentGroupStart = 0;
boolean currentGroupHasIcon = false;
for (int i = 0, totalSize = menu.getVisibleItems().size(); i < totalSize; i++) {
MenuItemImpl item = menu.getVisibleItems().get(i);
if (item.isChecked()) {
setCheckedItem(item);
}
if (item.isCheckable()) {
item.setExclusiveCheckable(false);
}
if (item.hasSubMenu()) {
SubMenu subMenu = item.getSubMenu();
if (subMenu.hasVisibleItems()) {
if (i != 0) {
items.add(new NavigationMenuSeparatorItem(paddingSeparator, 0));
}
items.add(new NavigationMenuTextItem(item));
boolean subMenuHasIcon = false;
int subMenuStart = items.size();
for (int j = 0, size = subMenu.size(); j < size; j++) {
MenuItemImpl subMenuItem = (MenuItemImpl) subMenu.getItem(j);
if (subMenuItem.isVisible()) {
if (!subMenuHasIcon && subMenuItem.getIcon() != null) {
subMenuHasIcon = true;
}
if (subMenuItem.isCheckable()) {
subMenuItem.setExclusiveCheckable(false);
}
if (item.isChecked()) {
setCheckedItem(item);
}
items.add(new NavigationMenuTextItem(subMenuItem));
}
}
if (subMenuHasIcon) {
appendTransparentIconIfMissing(subMenuStart, items.size());
}
}
} else {
int groupId = item.getGroupId();
if (groupId != currentGroupId) { // first item in group
currentGroupStart = items.size();
currentGroupHasIcon = item.getIcon() != null;
if (i != 0) {
currentGroupStart++;
items.add(new NavigationMenuSeparatorItem(paddingSeparator, paddingSeparator));
}
} else if (!currentGroupHasIcon && item.getIcon() != null) {
currentGroupHasIcon = true;
appendTransparentIconIfMissing(currentGroupStart, items.size());
}
NavigationMenuTextItem textItem = new NavigationMenuTextItem(item);
textItem.needsEmptyIcon = currentGroupHasIcon;
items.add(textItem);
currentGroupId = groupId;
}
}
updateSuspended = false;
}
开发者ID:material-components,项目名称:material-components-android,代码行数:73,代码来源:NavigationMenuPresenter.java
示例11: prepareMenuItems
import android.support.v7.view.menu.MenuItemImpl; //导入方法依赖的package包/类
/**
* Flattens the visible menu items of {@link #mMenu} into {@link #mItems}, while inserting
* separators between items when necessary.
*/
private void prepareMenuItems() {
if (mUpdateSuspended) {
return;
}
mUpdateSuspended = true;
mItems.clear();
mItems.add(new NavigationMenuHeaderItem());
int currentGroupId = -1;
int currentGroupStart = 0;
boolean currentGroupHasIcon = false;
for (int i = 0, totalSize = mMenu.getVisibleItems().size(); i < totalSize; i++) {
MenuItemImpl item = mMenu.getVisibleItems().get(i);
if (item.isChecked()) {
setCheckedItem(item);
}
if (item.isCheckable()) {
item.setExclusiveCheckable(false);
}
if (item.hasSubMenu()) {
SubMenu subMenu = item.getSubMenu();
if (subMenu.hasVisibleItems()) {
if (i != 0) {
mItems.add(new NavigationMenuSeparatorItem(mPaddingSeparator, 0));
}
mItems.add(new NavigationMenuTextItem(item));
boolean subMenuHasIcon = false;
int subMenuStart = mItems.size();
for (int j = 0, size = subMenu.size(); j < size; j++) {
MenuItemImpl subMenuItem = (MenuItemImpl) subMenu.getItem(j);
if (subMenuItem.isVisible()) {
if (!subMenuHasIcon && subMenuItem.getIcon() != null) {
subMenuHasIcon = true;
}
if (subMenuItem.isCheckable()) {
subMenuItem.setExclusiveCheckable(false);
}
if (item.isChecked()) {
setCheckedItem(item);
}
mItems.add(new NavigationMenuTextItem(subMenuItem));
}
}
if (subMenuHasIcon) {
appendTransparentIconIfMissing(subMenuStart, mItems.size());
}
}
} else {
int groupId = item.getGroupId();
if (groupId != currentGroupId) { // first item in group
currentGroupStart = mItems.size();
currentGroupHasIcon = item.getIcon() != null;
if (i != 0) {
currentGroupStart++;
mItems.add(new NavigationMenuSeparatorItem(mPaddingSeparator, mPaddingSeparator));
}
} else if (!currentGroupHasIcon && item.getIcon() != null) {
currentGroupHasIcon = true;
appendTransparentIconIfMissing(currentGroupStart, mItems.size());
}
NavigationMenuTextItem textItem = new NavigationMenuTextItem(item);
textItem.needsEmptyIcon = currentGroupHasIcon;
mItems.add(textItem);
currentGroupId = groupId;
}
}
mUpdateSuspended = false;
}