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


Java MenuItem类代码示例

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


MenuItem类属于com.actionbarsherlock.view包,在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onCreateOptionsMenu

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    int action = getResources().getBoolean(R.bool.menu_in_bar) ? MenuItem.SHOW_AS_ACTION_IF_ROOM : MenuItem.SHOW_AS_ACTION_NEVER;
    MenuItem delMenu = menu.add(isDigit ? R.string.switch_to_text : R.string.switch_to_digit);
    delMenu.setIcon(
            isDigit ? R.drawable.ic_menu_switch_txt
                    : R.drawable.ic_menu_switch_digit).setShowAsAction( action );
    delMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            setTextDialing(isDigit);
            return true;
        }
    });
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:18,代码来源:DialerFragment.java

示例3: setActionView

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
public MenuItem setActionView(View view) {
    mActionView = view;
    mActionProvider = null;
    if (view != null && view.getId() == View.NO_ID && mId > 0) {
        view.setId(mId);
    }
    mMenu.onItemActionRequestChanged(this);
    return this;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:10,代码来源:MenuItemImpl.java

示例4: ActionButtonSubmenu

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
    super(context, subMenu);
    //UNUSED mSubMenu = subMenu;

    MenuItemImpl item = (MenuItemImpl) subMenu.getItem();
    if (!item.isActionButton()) {
        // Give a reasonable anchor to nested submenus.
        setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton);
    }

    setCallback(mPopupPresenterCallback);

    boolean preserveIconSpacing = false;
    final int count = subMenu.size();
    for (int i = 0; i < count; i++) {
        MenuItem childItem = subMenu.getItem(i);
        if (childItem.isVisible() && childItem.getIcon() != null) {
            preserveIconSpacing = true;
            break;
        }
    }
    setForceShowIcon(preserveIconSpacing);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:24,代码来源:ActionMenuPresenter.java

示例5: onRestoreInstanceState

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public void onRestoreInstanceState(Parcelable p) {
    SavedState state = (SavedState) p;

    super.onRestoreInstanceState(state.getSuperState());

    if (state.expandedMenuItemId != 0 &&
            mExpandedMenuPresenter != null && mOptionsMenu != null) {
        final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId);
        if (item != null) {
            item.expandActionView();
        }
    }

    if (state.isOverflowOpen) {
        postShowOverflowMenu();
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:19,代码来源:ActionBarView.java

示例6: 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

示例7: onSubMenuSelected

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
    if (subMenu.hasVisibleItems()) {
        MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView, false);
        subPopup.setCallback(mPresenterCallback);

        boolean preserveIconSpacing = false;
        final int count = subMenu.size();
        for (int i = 0; i < count; i++) {
            MenuItem childItem = subMenu.getItem(i);
            if (childItem.isVisible() && childItem.getIcon() != null) {
                preserveIconSpacing = true;
                break;
            }
        }
        subPopup.setForceShowIcon(preserveIconSpacing);

        if (subPopup.tryShow()) {
            if (mPresenterCallback != null) {
                mPresenterCallback.onOpenSubMenu(subMenu);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:27,代码来源:MenuPopupHelper.java

示例8: onMenuItemSelected

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item);

    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        if (onOptionsItemSelected(item)) {
            return true;
        }

        if (mFragments.mAdded != null) {
            for (int i = 0; i < mFragments.mAdded.size(); i++) {
                Fragment f = mFragments.mAdded.get(i);
                if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnOptionsItemSelectedListener) {
                    if (((OnOptionsItemSelectedListener)f).onOptionsItemSelected(item)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:23,代码来源:Watson.java

示例9: onOptionsItemSelected

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == Compatibility.getHomeMenuId()) {
        finish();
        return true;
    }
    return false;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:9,代码来源:PrefsFilters.java

示例10: onOptionsItemSelected

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if(PrefsLogic.onMainActivityOptionsItemSelected(item, this, prefsWrapper)) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:8,代码来源:MainPrefs.java

示例11: 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

示例12: onOptionsItemSelected

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch(item.getItemId()){
	case android.R.id.home:
		startActivity(new Intent(this, LoginAty.class));
		break;
	}
	return super.onOptionsItemSelected(item);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:10,代码来源:ResetPwdAty.java

示例13: setCheckable

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
public MenuItem setCheckable(boolean checkable) {
    final int oldFlags = mFlags;
    mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0);
    if (oldFlags != mFlags) {
        mMenu.onItemsChanged(false);
    }

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

示例14: onOptionsItemSelected

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case android.R.id.home:
		startActivity(new Intent(this, MainActivity.class));
		finish();
		break;
	}
	return super.onOptionsItemSelected(item);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:11,代码来源:MoreAty.java

示例15: setIcon

import com.actionbarsherlock.view.MenuItem; //导入依赖的package包/类
public MenuItem setIcon(Drawable icon) {
    mIconResId = NO_ICON;
    mIconDrawable = icon;
    mMenu.onItemsChanged(false);

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


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