本文整理汇总了Java中android.view.MenuItem.hasSubMenu方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.hasSubMenu方法的具体用法?Java MenuItem.hasSubMenu怎么用?Java MenuItem.hasSubMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.hasSubMenu方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: restoreActionViewStates
import android.view.MenuItem; //导入方法依赖的package包/类
public void restoreActionViewStates(Bundle states) {
if (states != null) {
SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
int itemCount = size();
for (int i = 0; i < itemCount; i++) {
MenuItem item = getItem(i);
View v = MenuItemCompat.getActionView(item);
if (!(v == null || v.getId() == -1)) {
v.restoreHierarchyState(viewStates);
}
if (item.hasSubMenu()) {
((SubMenuBuilder) item.getSubMenu()).restoreActionViewStates(states);
}
}
int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
if (expandedId > 0) {
MenuItem itemToExpand = findItem(expandedId);
if (itemToExpand != null) {
MenuItemCompat.expandActionView(itemToExpand);
}
}
}
}
示例2: getItemViewType
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public int getItemViewType(int position) {
MenuItem item = getItem(position);
int viewCount = item.hasSubMenu() ? item.getSubMenu().size() : 1;
if (item.getItemId() == R.id.update_menu_id) {
return UPDATE_MENU_ITEM;
} else if (viewCount == 5) {
return FIVE_BUTTON_MENU_ITEM;
} else if (viewCount == 4) {
return FOUR_BUTTON_MENU_ITEM;
} else if (viewCount == 3) {
return THREE_BUTTON_MENU_ITEM;
} else if (viewCount == 2) {
return TITLE_BUTTON_MENU_ITEM;
}
return STANDARD_MENU_ITEM;
}
示例3: tintMenuItems
import android.view.MenuItem; //导入方法依赖的package包/类
public ContextUtils tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) {
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
tintDrawable(item.getIcon(), iconColor);
if (item.hasSubMenu() && recurse) {
tintMenuItems(item.getSubMenu(), recurse, iconColor);
}
}
return this;
}
示例4: onClick
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
final MenuItem item = menu.findItem(v.getId());
if (item == null) return;
if (item.hasSubMenu()) {
showMenu(item.getSubMenu());
} else if (itemSelectedListener != null) {
itemSelectedListener.onMenuItemClick(item);
}
}
示例5: shouldAddChooserIntent
import android.view.MenuItem; //导入方法依赖的package包/类
boolean shouldAddChooserIntent(MenuItem item) {
return !item.hasSubMenu();
}
示例6: createAdapterItems
import android.view.MenuItem; //导入方法依赖的package包/类
private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor,
int itemTextColor, int itemBackground,
int tintColor) {
List<BottomSheetItem> items = new ArrayList<>();
mTitles = 0;
boolean addedSubMenu = false;
for (int i = 0; i < mMenu.size(); i++) {
MenuItem item = mMenu.getItem(i);
if (item.isVisible()) {
if (item.hasSubMenu()) {
SubMenu subMenu = item.getSubMenu();
if (i != 0 && addedSubMenu) {
if (mMode == BottomSheetBuilder.MODE_GRID) {
throw new IllegalArgumentException("MODE_GRID can't have submenus." +
" Use MODE_LIST instead");
}
items.add(new BottomSheetDivider(dividerBackground));
}
CharSequence title = item.getTitle();
if (title != null && !title.equals("")) {
items.add(new BottomSheetHeader(title.toString(), titleTextColor));
mTitles++;
}
for (int j = 0; j < subMenu.size(); j++) {
MenuItem subItem = subMenu.getItem(j);
if (subItem.isVisible()) {
items.add(new BottomSheetMenuItem(subItem,itemTextColor, itemBackground, tintColor));
addedSubMenu = true;
}
}
} else {
items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor));
}
}
}
return items;
}