本文整理匯總了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);
}
示例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;
}
示例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: 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));
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}