本文整理汇总了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;
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}