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


Java Menu.size方法代码示例

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


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

示例1: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.main, menu);
  // the support toolbar should probably do this by default
  final TypedArray styles =
      obtainStyledAttributes(R.style.AppTheme_Toolbar, new int[]{R.attr.colorControlNormal});
  try {
    int tintColor = styles.getColor(0, Color.BLACK);
    for (int i = 0; i < menu.size(); i++) {
      Drawable icon = menu.getItem(i).getIcon();
      if (icon != null) {
        DrawableCompat.setTint(icon, tintColor);
      }
    }
  } finally {
    styles.recycle();
  }
  return super.onCreateOptionsMenu(menu);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:MainActivity.java

示例2: onPrepareOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
public boolean onPrepareOptionsMenu(Menu menu) {
    if (menu != null && menu.size() > 0) {
        menu.findItem(R.id.action_bind).setVisible(this.stepManager.isPedometer());
        if (StepApi.isCurrentMonth(this.mDate)) {
            menu.findItem(R.id.action_share).setVisible(true);
            menu.findItem(R.id.action_history).setVisible(true);
            menu.findItem(R.id.action_bind).setVisible(true);
            menu.findItem(R.id.action_setting).setVisible(true);
        } else {
            menu.findItem(R.id.action_share).setVisible(false);
            menu.findItem(R.id.action_history).setVisible(false);
            menu.findItem(R.id.action_bind).setVisible(false);
            menu.findItem(R.id.action_setting).setVisible(false);
        }
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:StepMainActivity.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: savePrevMenuState

import android.view.Menu; //导入方法依赖的package包/类
private void savePrevMenuState() {
    Menu menu = actionBar.getMenu();
    if (menu != null) {
        prevState.menuItems = new HashSet<>(menu.size());
        for (int index = 0; index < menu.size(); index++) {
            prevState.menuItems.add(menu.getItem(index));
        }
    }
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:10,代码来源:MultiMode.java

示例6: 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,项目名称:simple-stack,代码行数:8,代码来源:MainActivity.java

示例7: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_parse, menu);
    for (int c = 0; c < menu.size(); c++) {
        MenuItem item = menu.getItem(c);
        Drawable drawable = item.getIcon();
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, ContextCompat.getColor(this, R.color.colorAccent));
        item.setIcon(drawable);
    }
    return true;
}
 
开发者ID:solkin,项目名称:minion-android,代码行数:13,代码来源:ParseActivity.java

示例8: MyOnNavigationItemSelectedListener

import android.view.Menu; //导入方法依赖的package包/类
MyOnNavigationItemSelectedListener(ViewPager viewPager, BottomNavigationViewEx bnve, boolean smoothScroll, OnNavigationItemSelectedListener listener) {
    this.viewPagerRef = new WeakReference<>(viewPager);
    this.listener = listener;
    this.smoothScroll = smoothScroll;

    // create items
    Menu menu = bnve.getMenu();
    int size = menu.size();
    items = new SparseIntArray(size);
    for (int i = 0; i < size; i++) {
        int itemId = menu.getItem(i).getItemId();
        items.put(itemId, i);
    }
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:15,代码来源:BottomNavigationViewEx.java

示例9: 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

示例10: onPrepareOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  super.onPrepareOptionsMenu(menu);

  //debug Log.d("DEBUG", "onPrepareOptionsMenu");

  String barTitle;
  if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) {
    barTitle = getSupportActionBar().getTitle().toString();

    Log.d("DEBUG", "Title = " + barTitle);

    if (barTitle.length() > 1) {
      for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        String title = item.getTitle().toString();

        if (title.contains(" (for Eye VDJ)")) {
          title = title.substring(0, title.indexOf(" (for Eye VDJ)"));
        }

        if (barTitle.contains(title)) {
          item.setVisible(false);
        } else {
          item.setVisible(true);
        }
      }
    } else {
      for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setVisible(true);
      }
    }
  }

  return true;
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:37,代码来源:MainActivity.java

示例11: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    if (menu != null && menu.size() > 0) {
        menu.clear();
    }
    if (this.address_type == 1) {
        menu.add(0, 1, 1, R.string.b0).setShowAsAction(2);
    } else if (this.address_type == 2) {
        menu.add(0, 1, 1, R.string.aat).setShowAsAction(2);
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:AddressEditActivity.java

示例12: setPreviousSelectedItemIdInternal

import android.view.Menu; //导入方法依赖的package包/类
private void setPreviousSelectedItemIdInternal() {
    final Menu menu = getMenu();

    for (int i = 0; i < menu.size(); i++) {
        final MenuItem item = menu.getItem(i);

        if (item.isChecked()) {
            mPreviousSelectedItemId = item.getItemId();
            break;
        }
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:13,代码来源:HistoryAwareBottomNavigationView.java

示例13: tint

import android.view.Menu; //导入方法依赖的package包/类
/**
 * Tint all menu items within a menu to be a certain color. Note that this does not tint the
 * overflow menu. Call {@link #tintOverflow(Toolbar, int)} for that.
 *
 * @param menu  the menu
 * @param color the color
 */
public static void tint(@NonNull Menu menu, @ColorInt int color) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        if (menuItem.getIcon() != null) {
            tint(menuItem, color);
        }
    }
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:16,代码来源:Easel.java

示例14: 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

示例15: onPrepareOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (menu.size() == 1) {
        MenuItem item = menu.getItem(0);
        if (item.getIcon() != null) item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    return super.onPrepareOptionsMenu(menu);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:9,代码来源:Preferences.java


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