当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem.getSubMenu方法代码示例

本文整理汇总了Java中com.actionbarsherlock.view.MenuItem.getSubMenu方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.getSubMenu方法的具体用法?Java MenuItem.getSubMenu怎么用?Java MenuItem.getSubMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.actionbarsherlock.view.MenuItem的用法示例。


在下文中一共展示了MenuItem.getSubMenu方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveActionViewStates

import com.actionbarsherlock.view.MenuItem; //导入方法依赖的package包/类
public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }

    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:27,代码来源:MenuBuilder.java

示例2: restoreActionViewStates

import com.actionbarsherlock.view.MenuItem; //导入方法依赖的package包/类
public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
            getActionViewStatesKey());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) {
        //Fixes Issue #652 with sdk <= 2.3.6
        return;
    }

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:35,代码来源:MenuBuilder.java

示例3: performItemAction

import com.actionbarsherlock.view.MenuItem; //导入方法依赖的package包/类
public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
        invoked |= itemImpl.expandActionView();
        if (invoked) close(true);
    } else if (item.hasSubMenu()) {
        close(false);

        final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
        final ActionProvider provider = item.getActionProvider();
        if (provider != null && provider.hasSubMenu()) {
            provider.onPrepareSubMenu(subMenu);
        }
        invoked |= dispatchSubMenuSelected(subMenu);
        if (!invoked) close(true);
    } else {
        if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
            close(true);
        }
    }

    return invoked;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:31,代码来源:MenuBuilder.java

示例4: onRestoreInstanceState

import com.actionbarsherlock.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:ActionMenuPresenter.java


注:本文中的com.actionbarsherlock.view.MenuItem.getSubMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。