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