Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Defi...
If you think the Android project ActionBarTest listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2006 The Android Open Source Project
*//www.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.actionbarsherlock.internal.view.menu;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.SubMenu;
/**
* The model for a sub menu, which is an extension of the menu. Most methods are proxied to
* the parent menu.
*/publicclass SubMenuBuilder extends MenuBuilder implements SubMenu {
private MenuBuilder mParentMenu;
private MenuItemImpl mItem;
public SubMenuBuilder(Context context, MenuBuilder parentMenu, MenuItemImpl item) {
super(context);
mParentMenu = parentMenu;
mItem = item;
}
@Override
publicvoid setQwertyMode(boolean isQwerty) {
mParentMenu.setQwertyMode(isQwerty);
}
@Override
publicboolean isQwertyMode() {
return mParentMenu.isQwertyMode();
}
@Override
publicvoid setShortcutsVisible(boolean shortcutsVisible) {
mParentMenu.setShortcutsVisible(shortcutsVisible);
}
@Override
publicboolean isShortcutsVisible() {
return mParentMenu.isShortcutsVisible();
}
public Menu getParentMenu() {
return mParentMenu;
}
public MenuItem getItem() {
return mItem;
}
@Override
publicvoid setCallback(Callback callback) {
mParentMenu.setCallback(callback);
}
@Override
public MenuBuilder getRootMenu() {
return mParentMenu;
}
@Override
boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) {
return super.dispatchMenuItemSelected(menu, item) ||
mParentMenu.dispatchMenuItemSelected(menu, item);
}
public SubMenu setIcon(Drawable icon) {
mItem.setIcon(icon);
returnthis;
}
public SubMenu setIcon(int iconRes) {
mItem.setIcon(iconRes);
returnthis;
}
public SubMenu setHeaderIcon(Drawable icon) {
return (SubMenu) super.setHeaderIconInt(icon);
}
public SubMenu setHeaderIcon(int iconRes) {
return (SubMenu) super.setHeaderIconInt(iconRes);
}
public SubMenu setHeaderTitle(CharSequence title) {
return (SubMenu) super.setHeaderTitleInt(title);
}
public SubMenu setHeaderTitle(int titleRes) {
return (SubMenu) super.setHeaderTitleInt(titleRes);
}
public SubMenu setHeaderView(View view) {
return (SubMenu) super.setHeaderViewInt(view);
}
@Override
publicboolean expandItemActionView(MenuItemImpl item) {
return mParentMenu.expandItemActionView(item);
}
@Override
publicboolean collapseItemActionView(MenuItemImpl item) {
return mParentMenu.collapseItemActionView(item);
}
@Override
public String getActionViewStatesKey() {
finalint itemId = mItem != null ? mItem.getItemId() : 0;
if (itemId == 0) {
return null;
}
return super.getActionViewStatesKey() + ":" + itemId;
}
}