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