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


Java MenuItem.getSubMenu方法代码示例

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


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

示例1: onActionItemClicked

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);

    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            displayScheduleTimestampDialog(R.id.query_cab_schedule, mSelection.getIds());
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    mListener.onStateChangeRequest(mSelection.getIds(), menuItem.getTitle().toString());
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:35,代码来源:SearchFragment.java

示例2: onActionItemClicked

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);
    TreeSet<Long> selectionIds;
    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            selectionIds = originalSelectedIds();
            if (!selectionIds.isEmpty()) {
                displayScheduleTimestampDialog(R.id.query_cab_schedule, selectionIds);
            }
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    selectionIds = originalSelectedIds();
                    if (!selectionIds.isEmpty()) {
                        mListener.onStateChangeRequest(selectionIds, menuItem.getTitle().toString());
                    }
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:41,代码来源:AgendaFragment.java

示例3: getSelectedMenu

import android.view.MenuItem; //导入方法依赖的package包/类
public static MenuItem getSelectedMenu(@NonNull MenuItem menuItem) {
    if (menuItem.getSubMenu() == null || menuItem.getSubMenu().size() == 0) {
        return null;
    }
    MenuItem selected = null;
    for (int i = 0; i < menuItem.getSubMenu().size(); i++) {
        MenuItem item = menuItem.getSubMenu().getItem(i);
        if (item.isChecked()) {
            selected = item;
            break;
        }
    }
    return selected;
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:15,代码来源:ViewUtils.java

示例4: onCreate

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setupToolbar(R.id.toolbar, "COOK IT", R.color.colorPink, R.color.colorWhiteTrans, R.drawable.ic_burger);

    FragmentTransaction ft;
    FragmentHome fragmentHome = new FragmentHome();
    ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.frameLayout, fragmentHome).commit();

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    Menu m = navigationView.getMenu();
    for (int i=0;i<m.size();i++) {
        MenuItem mi = m.getItem(i);
        SubMenu subMenu = mi.getSubMenu();
        if (subMenu!=null && subMenu.size() >0 ) {
            for (int j=0; j <subMenu.size();j++) {
                MenuItem subMenuItem = subMenu.getItem(j);
                applyFontToMenuItem(subMenuItem);
            }
        }
        applyFontToMenuItem(mi);
    }

    View header = navigationView.getHeaderView(0);
    ImageView imageView = (ImageView) header.findViewById(R.id.imageView);
    Glide.with(this)
            .load(Uri.parse("https://s3.amazonaws.com/uifaces/faces/twitter/jsa/128.jpg"))
            .transform(new CircleGlide(this))
            .into(imageView);
}
 
开发者ID:ahmadnurhidayat,项目名称:Cook-It-Android-XML-Template,代码行数:42,代码来源:Main.java

示例5: 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;
}
 
开发者ID:yuhodev,项目名称:login,代码行数:44,代码来源:BottomSheetAdapterBuilder.java


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