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


Java MenuRes类代码示例

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


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

示例1: inflateMenu

import android.support.annotation.MenuRes; //导入依赖的package包/类
public void inflateMenu(@MenuRes int menuRes) {
    if(menuRes == 0) return;
    if (isInEditMode()) return;
    getActivity().getMenuInflater().inflate(menuRes, mActionMenu.getMenu());

    XmlResourceParser parser = null;
    try {
        //noinspection ResourceType
        parser = getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs);
    } catch (XmlPullParserException | IOException e) {
        // should not happens
        throw new InflateException("Error parsing menu XML", e);
    } finally {
        if (parser != null) parser.close();
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:19,代码来源:FloatingSearchView.java

示例2: switchId

import android.support.annotation.MenuRes; //导入依赖的package包/类
@Override
public void switchId(@MenuRes int id) {
    switch (id) {
        case R.id.dytt:
        case FIRST_FRAGMENT:
            setSelectFragment(TYPE_DYTT_FRAGMENT);
            break;
        case R.id.dy_2018:
            setSelectFragment(TYPE_DY2018_FRAGMENT);
            break;
        case R.id.xiaopian:
            setSelectFragment(TYPE_XP_FRAGMENT);
            break;
        case R.id.piaohua:
            setSelectFragment(TYPE_PH_FRAGMENT);
            break;
        case R.id.k567:
            setSelectFragment(TYPE_K567_FRAGMENT);
            break;
    }
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:22,代码来源:MainPresenterImpl.java

示例3: switchId

import android.support.annotation.MenuRes; //导入依赖的package包/类
@Override
public void switchId(@MenuRes int id) {
    switch (id) {
        case R.id.search:
            view.switchSearch();
            break;
        case R.id.mark:
            view.switchMark();
            break;
        case FIRST_FRAGMENT:
        case R.id.fiction_81:
            setSelectFragment(TYPE_ZW_FRAGMENT);
            break;
        case R.id.bi_qu_ge:
            setSelectFragment(TYPE_BGQ_FRAGMENT);
            break;
        case R.id.ksw:
            setSelectFragment(TYPE_KSW_FRAGMENT);
            break;
        case R.id.piao_tian:
            setSelectFragment(TYPE_PT_FRAGMENT);
            break;
    }
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:25,代码来源:MainPresenterImpl.java

示例4: switchId

import android.support.annotation.MenuRes; //导入依赖的package包/类
@Override
public void switchId(@MenuRes int id) {
    switch (id) {
        case R.id.mzitu:
            setSelectFragment(TYPE_MZT_FRAGMENT);
            break;
        case FIRST_FRAGMENT:
        case R.id.dbmz:
            setSelectFragment(TYPE_DB_FRAGMENT);
            break;
        case R.id.mm:
            setSelectFragment(TYPE_MM_FRAGMENT);
            break;
        case R.id.meizitu:
            setSelectFragment(TYPE_MEIZITU_FRAGMENT);
            break;
        case R.id.kk:
            setSelectFragment(TYPE_KK_FRAGMENT);
            break;
        case R.id.collection:
            setSelectFragment(TYPE_COLLECTION_FRAGMENT);
            break;
        case R.id.search:
            view.switchSearch();
    }
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:27,代码来源:MainPresenterImpl.java

示例5: inflateMenu

import android.support.annotation.MenuRes; //导入依赖的package包/类
public void inflateMenu(@MenuRes int menuRes) {
    if (menuRes == 0) return;
    getActivity().getMenuInflater()
                 .inflate(menuRes, mActionMenu.getMenu());

    XmlResourceParser parser = null;
    try {
        //noinspection ResourceType
        parser = getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs);
    } catch (XmlPullParserException | IOException e) {
        // should not happens
        throw new InflateException("Error parsing menu XML", e);
    } finally {
        if (parser != null) parser.close();
    }
}
 
开发者ID:SamuelGjk,项目名称:GComic,代码行数:19,代码来源:FloatingSearchView.java

示例6: switchMenuTo

import android.support.annotation.MenuRes; //导入依赖的package包/类
/**
 * Provides a mechanism for switching between any number of Menus.
 *
 * @param newMenuResId id of the menu that you wish
 *                     to switch to. Eg: R.menu.new_menu_id
 */
public void switchMenuTo(@MenuRes int newMenuResId) {
    if (newMenuResId < 1) {
        Log.e(TAG, "Could not switch to new menu: passed menuResourceId was invalid.");
        return;
    }

    mMenu = new SublimeMenu(newMenuResId);
    inflateMenu(newMenuResId);

    mMenu.setCallback(new SublimeMenu.Callback() {
        public boolean onMenuItemSelected(SublimeMenu menu, SublimeBaseMenuItem item,
                                          OnNavigationMenuEventListener.Event event) {
            return SublimeNavigationView.this.mEventListener != null
                    && SublimeNavigationView.this
                    .mEventListener.onNavigationMenuEvent(event, item);
        }
    });

    mMenu.setMenuPresenter(getContext(), mPresenter);
}
 
开发者ID:vikramkakkar,项目名称:SublimeNavigationView,代码行数:27,代码来源:SublimeNavigationView.java

示例7: reinflateMenu

import android.support.annotation.MenuRes; //导入依赖的package包/类
/**
 * Clears and inflates the menu.
 *
 * @param menuResId The menu resource XML to be used.
 */
public static ViewAction reinflateMenu(final @MenuRes int menuResId) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(NavigationView.class);
    }

    @Override
    public String getDescription() {
      return "clear and inflate menu " + menuResId;
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();
      final NavigationView nv = (NavigationView) view;
      nv.getMenu().clear();
      nv.inflateMenu(menuResId);
      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:28,代码来源:TestUtilsActions.java

示例8: inflateMenu

import android.support.annotation.MenuRes; //导入依赖的package包/类
@Override
public void inflateMenu(@MenuRes int resId) {
    super.inflateMenu(resId);
    Menu menu = getMenu();
    MenuItem item = menu.getItem(0);
    int size = item.getIcon().getIntrinsicWidth() + ControlHelper.dpToPx(30, getResources());
    int width = getWidth();

    for (int i = 0; i < menu.size(); i++) {
        item = menu.getItem(i);
        if (size * (i + 2) < width)
            MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
        else
            break;
    }
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:17,代码来源:BottomToolbar.java

示例9: setMenuRes

import android.support.annotation.MenuRes; //导入依赖的package包/类
public void setMenuRes(@MenuRes int menuGeneral, @MenuRes int menuSpecific, @MenuRes int menuMerged) {
    toolbarSpecific.getMenu().clear();
    if (toolbarGeneral != null) {
        toolbarGeneral.getMenu().clear();
        toolbarGeneral.inflateMenu(menuGeneral);
        toolbarSpecific.inflateMenu(menuSpecific);
    } else {
        toolbarSpecific.inflateMenu(menuMerged);
    }
}
 
开发者ID:lurbas,项目名称:MaterialMasterDetail,代码行数:11,代码来源:CustomAppBar.java

示例10: getMoreMenuRes

import android.support.annotation.MenuRes; //导入依赖的package包/类
@MenuRes
public int getMoreMenuRes() {
    if (isAutomatic()) {
        return R.menu.automatic_collection;
    } else {
        if (!isFavourie()) {
            return R.menu.user_collection;
        } else {
            return R.menu.favourite_collection;
        }
    }
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:13,代码来源:BooksCollection.java

示例11: MenuSecondaryItemsAdapter

import android.support.annotation.MenuRes; //导入依赖的package包/类
MenuSecondaryItemsAdapter(Context context, @MenuRes int secondaryMenuId, View.OnClickListener onClickListener,
                                 @ColorInt int foregroundColour) {
    this.context = context;
    this.onClickListener = onClickListener;
    this.foregroundColour = foregroundColour;
    this.itemss = new ArrayList<>();

    MenuParserHelper.parseMenu(context, secondaryMenuId, itemss);
}
 
开发者ID:byvlstr,项目名称:fluentAppBar,代码行数:10,代码来源:MenuSecondaryItemsAdapter.java

示例12: setNavigationMenu

import android.support.annotation.MenuRes; //导入依赖的package包/类
public void setNavigationMenu(@MenuRes int menuRes, OnClickListener onClickListener) {
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.nav_items_recycler);
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
    menuNavigationItemsAdapter = new MenuNavigationItemsAdapter(getContext(), menuRes, onClickListener,
            foregroundColour);
    recyclerView.setAdapter(menuNavigationItemsAdapter);
}
 
开发者ID:byvlstr,项目名称:fluentAppBar,代码行数:9,代码来源:FluentAppBar.java

示例13: setSecondaryMenu

import android.support.annotation.MenuRes; //导入依赖的package包/类
public void setSecondaryMenu(@MenuRes int menuRes, OnClickListener onClickListener) {
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.secondary_menu_items_recyler);
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    menuSecondaryItemsAdapter = new MenuSecondaryItemsAdapter(getContext(), menuRes, onClickListener,
            foregroundColour);
    recyclerView.setAdapter(menuSecondaryItemsAdapter);
}
 
开发者ID:byvlstr,项目名称:fluentAppBar,代码行数:9,代码来源:FluentAppBar.java

示例14: parseMenu

import android.support.annotation.MenuRes; //导入依赖的package包/类
public static void parseMenu(Context context, @MenuRes int menuRes, List<MenuEntry> menuEntryList){
    PopupMenu p = new PopupMenu(context, null);
    Menu menu = p.getMenu();
    new MenuInflater(context).inflate(menuRes, menu);

    for (int i = 0; i < menu.size(); i++) {
        android.view.MenuItem item = menu.getItem(i);
        menuEntryList.add(new MenuEntry(item.getTitle().toString(), item.getIcon(), item.getItemId()));
    }
}
 
开发者ID:byvlstr,项目名称:fluentAppBar,代码行数:11,代码来源:MenuParserHelper.java

示例15: MenuNavigationItemsAdapter

import android.support.annotation.MenuRes; //导入依赖的package包/类
MenuNavigationItemsAdapter(Context context, @MenuRes int menuRes, View.OnClickListener onClickListener,
                                  @ColorInt int foregroundColour) {
    this.context = context;
    this.onClickListener = onClickListener;
    this.foregroundColour = foregroundColour;
    this.navItems = new ArrayList<>();

    populateNavigationItems(menuRes);
}
 
开发者ID:byvlstr,项目名称:fluentAppBar,代码行数:10,代码来源:MenuNavigationItemsAdapter.java


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