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


Java Menu.getItem方法代码示例

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


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

示例1: resolveActionMode

import android.view.Menu; //导入方法依赖的package包/类
/**
 * 处理item,处理点击
 * @param actionMode
 */
private ActionMode resolveActionMode(ActionMode actionMode) {
    if (actionMode != null) {
        final Menu menu = actionMode.getMenu();
        mActionMode = actionMode;
        menu.clear();
        for (int i = 0; i < mActionList.size(); i++) {
            menu.add(mActionList.get(i));
        }
        for (int i = 0; i < menu.size(); i++) {
            MenuItem menuItem = menu.getItem(i);
            menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    getSelectedData((String) item.getTitle());
                    releaseAction();
                    return true;
                }
            });
        }
    }
    mActionMode = actionMode;
    return actionMode;
}
 
开发者ID:CarGuo,项目名称:CustomActionWebView,代码行数:28,代码来源:CustomActionWebView.java

示例2: setupWithMenu

import android.view.Menu; //导入方法依赖的package包/类
/**
 * Setups the tab switcher to be associated with those menu items of a specific menu, which use
 * a {@link TabSwitcherButton} as their action view. The icon of such menu items will
 * automatically be updated, when the number of tabs, which are contained by the tab switcher,
 * changes.
 *
 * @param tabSwitcher
 *         The tab switcher, which should become associated with the menu items, as an instance
 *         of the class {@link TabSwitcher}. The tab switcher may not be null
 * @param menu
 *         The menu, whose menu items should become associated with the given tab switcher, as
 *         an instance of the type {@link Menu}. The menu may not be null
 * @param listener
 *         The listener, which should be set to the menu items, which use a {@link
 *         TabSwitcherButton} as their action view, as an instance of the type {@link
 *         OnClickListener} or null, if no listener should be set
 */
public static void setupWithMenu(@NonNull final TabSwitcher tabSwitcher,
                                 @NonNull final Menu menu,
                                 @Nullable final OnClickListener listener) {
    ensureNotNull(tabSwitcher, "The tab switcher may not be null");
    ensureNotNull(menu, "The menu may not be null");

    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        View view = menuItem.getActionView();

        if (view instanceof TabSwitcherButton) {
            TabSwitcherButton tabSwitcherButton = (TabSwitcherButton) view;
            tabSwitcherButton.setOnClickListener(listener);
            tabSwitcherButton.setCount(tabSwitcher.getCount());
            tabSwitcher.addListener(tabSwitcherButton);
        }
    }
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:36,代码来源:TabSwitcher.java

示例3: themeChange

import android.view.Menu; //导入方法依赖的package包/类
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {
    ThemeEnum th = appPreference.getTheme();
    int[] cs = ColorUtils.get10ThemeColors(activity, th);
    int mainBC = cs[3];
    int mainTC = cs[5];
    int vicTC = cs[6];
    int accentC = cs[2];

    navigationView.setItemTextColor(ColorStateList.valueOf(mainTC));
    navigationView.setBackgroundColor(mainBC);

    updateSwitchMenuIconAndText();

    Menu menu = navigationView.getMenu();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(0);
            Drawable icon = item.getIcon();
            if (icon != null) {
                icon.setTint(accentC);
            }
        }
    }
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:26,代码来源:LeftNavigationController.java

示例4: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_main, menu);

    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        switch (menuItem.getItemId()) {
            case R.id.action_share:
                menuItem.setTitle(StringsManager.getString("menu_share_app"));
                break;
            case R.id.action_language:
                menuItem.setTitle(StringsManager.getString("menu_language"));
                break;
        }
    }

    if (mFragment instanceof ShareFragment) {
        menu.findItem(R.id.action_share).setVisible(true);
        menu.findItem(R.id.action_language).setVisible(false);
    } else {
        menu.findItem(R.id.action_share).setVisible(false);
        menu.findItem(R.id.action_language).setVisible(true);
    }
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:27,代码来源:MainActivity.java

示例5: onPrepareOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        switch (item.getItemId()) {
            case R.id.reload_option:
            case R.id.custom_option:
                // show only when loading is complete
                item.setVisible(mSwitcher.getDisplayedChild() == 1);
                continue;
            default:
                break;
        }
    }
    return super.onPrepareOptionsMenu(menu);
}
 
开发者ID:vanilla-music,项目名称:vanilla-music-cover-fetch,代码行数:17,代码来源:CoverShowActivity.java

示例6: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(
			mIsCreating ? R.menu.edit_host_activity_add_menu : R.menu.edit_host_activity_edit_menu,
			menu);

	mSaveHostButton = menu.getItem(0);

	// If the new host is being created, it can't be added until modifications have been made.
	setAddSaveButtonEnabled(!mIsCreating);

	return super.onCreateOptionsMenu(menu);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:EditHostActivity.java

示例7: setActiveTab

import android.view.Menu; //导入方法依赖的package包/类
@ReactProp(name = "activeTab", defaultInt = 0)
public void setActiveTab(RNBottomNavigation view, int activeTab) {
    Menu menu = view.getMenu();

    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        if (i == activeTab) {
            menuItem.setChecked(true);
        } else {
            menuItem.setChecked(false);
        }
    }
}
 
开发者ID:timomeh,项目名称:react-native-android-bottom-navigation,代码行数:14,代码来源:RNBottomNavigationManager.java

示例8: setupBottomNavigationBar

import android.view.Menu; //导入方法依赖的package包/类
private void setupBottomNavigationBar() {
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavViewBar);
    BottomNavigationViewHelper.enableNavigation(UploadActivity.this, bottomNavigationView);
    Menu menu = bottomNavigationView.getMenu();
    MenuItem menuItem = menu.getItem(ACTIVITY_NUMBER);
    menuItem.setChecked(true);
}
 
开发者ID:sindhu732,项目名称:instagram_clone,代码行数:8,代码来源:UploadActivity.java

示例9: setupBottomNavigationBar

import android.view.Menu; //导入方法依赖的package包/类
private void setupBottomNavigationBar() {
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavViewBar);
    BottomNavigationViewHelper.enableNavigation(AccountActivity.this, bottomNavigationView);
    Menu menu = bottomNavigationView.getMenu();
    MenuItem menuItem = menu.getItem(ACTIVITY_NUMBER);
    menuItem.setChecked(true);
}
 
开发者ID:sindhu732,项目名称:instagram_clone,代码行数:8,代码来源:AccountActivity.java

示例10: tintMenuItems

import android.view.Menu; //导入方法依赖的package包/类
public ContextUtils tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        tintDrawable(item.getIcon(), iconColor);
        if (item.hasSubMenu() && recurse) {
            tintMenuItems(item.getSubMenu(), recurse, iconColor);
        }
    }
    return this;
}
 
开发者ID:gsantner,项目名称:memetastic,代码行数:11,代码来源:ContextUtils.java

示例11: setCheckedItem

import android.view.Menu; //导入方法依赖的package包/类
private void setCheckedItem(int navigationItemId) {
    Menu menu = navigationView.getMenu();
    for(int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        menuItem.setChecked(menuItem.getItemId() == navigationItemId);
    }
}
 
开发者ID:Zhuinden,项目名称:navigator,代码行数:8,代码来源:MainView.java

示例12: setItemsVisibility

import android.view.Menu; //导入方法依赖的package包/类
private void setItemsVisibility(final Menu menu, boolean visible) {
    refreshFlag = visible;
    for (int i = 0; i < menu.size(); ++i) {
        MenuItem item = menu.getItem(i);
        item.setVisible(visible);
    }
}
 
开发者ID:HitRoxxx,项目名称:FloatingNew,代码行数:8,代码来源:MainActivity.java

示例13: onNavigationItemSelected

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
    Menu menu = navigationView.getMenu();
    for (int i = 0; i < menu.size(); i++) {
        MenuItem mi = menu.getItem(i);
        if (!(mi.getItemId() == menuItem.getItemId())) {
            mi.setCheckable(false);
        }
    }
    menuItem.setCheckable(true);
    if (menuItem.getTitle().equals(getResources().getString(R.string.logout))) {
        menuItem.setChecked(false);
    } else {
        menuItem.setChecked(true);
    }
    mNavItemId = menuItem.getItemId();

    // allow some time after closing the drawer before performing real navigation
    // so the user can see what is happening
    drawerLayout.closeDrawer(GravityCompat.START);
    drawerActionHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            navigate(menuItem.getItemId());
        }
    }, DRAWER_CLOSE_DELAY_MS);
    return true;
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:29,代码来源:SubscriberActivity.java

示例14: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_search, menu);
    mActionClear = menu.getItem(0);

    if (!TextUtils.isEmpty(mSearchEditText.getText().toString().trim()))
        mActionClear.setVisible(true);
}
 
开发者ID:alphater,项目名称:garras,代码行数:10,代码来源:SearchFragment.java

示例15: addActions

import android.view.Menu; //导入方法依赖的package包/类
/**
 * Add actions to the QuickActionView from the given menu resource id.
 *
 * @param menuId menu resource id
 * @return the QuickActionView
 */
public QuickActionView addActions(@MenuRes int menuId) {
    Menu menu = new MenuBuilder(mContext);
    new MenuInflater(mContext).inflate(menuId, menu);
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        Action action = new Action(item.getItemId(), item.getIcon(), item.getTitle());
        addAction(action);
    }
    return this;
}
 
开发者ID:ovenbits,项目名称:QuickActionView,代码行数:17,代码来源:QuickActionView.java


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