當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。