本文整理匯總了Java中android.view.MenuItem.isVisible方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.isVisible方法的具體用法?Java MenuItem.isVisible怎麽用?Java MenuItem.isVisible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.isVisible方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showMenu
import android.view.MenuItem; //導入方法依賴的package包/類
private void showMenu(Menu menu) {
if (currentMenu == menu) {
// no need to re-draw
return;
}
menuLayout.removeAllViews();
final int count = menu.size();
for (int i=0; i<count; i++) {
final MenuItem item = menu.getItem(i);
if (item.isVisible()) {
final View view = getMenuItemView(item);
menuLayout.addView(view);
}
}
currentMenu = menu;
}
示例2: onSubMenuSelected
import android.view.MenuItem; //導入方法依賴的package包/類
public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
if (subMenu.hasVisibleItems()) {
MenuPopupHelper subPopup = new MenuPopupHelper(this.mContext, subMenu, this.mAnchorView);
subPopup.setCallback(this.mPresenterCallback);
boolean preserveIconSpacing = false;
int count = subMenu.size();
for (int i = 0; i < count; i++) {
MenuItem childItem = subMenu.getItem(i);
if (childItem.isVisible() && childItem.getIcon() != null) {
preserveIconSpacing = true;
break;
}
}
subPopup.setForceShowIcon(preserveIconSpacing);
if (subPopup.tryShow()) {
if (this.mPresenterCallback != null) {
this.mPresenterCallback.onOpenSubMenu(subMenu);
}
return true;
}
}
return false;
}
示例3: ActionButtonSubmenu
import android.view.MenuItem; //導入方法依賴的package包/類
public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
super(context, subMenu, null, false, R.attr.actionOverflowMenuStyle);
this.mSubMenu = subMenu;
if (!((MenuItemImpl) subMenu.getItem()).isActionButton()) {
setAnchorView(ActionMenuPresenter.this.mOverflowButton == null ? (View) ActionMenuPresenter.this.mMenuView : ActionMenuPresenter.this.mOverflowButton);
}
setCallback(ActionMenuPresenter.this.mPopupPresenterCallback);
boolean preserveIconSpacing = false;
int count = subMenu.size();
for (int i = 0; i < count; i++) {
MenuItem childItem = subMenu.getItem(i);
if (childItem.isVisible() && childItem.getIcon() != null) {
preserveIconSpacing = true;
break;
}
}
setForceShowIcon(preserveIconSpacing);
}
示例4: addMenuItems
import android.view.MenuItem; //導入方法依賴的package包/類
private void addMenuItems() {
ViewCompat.setAlpha(menuItemsLayout, 1f);
for (int i = 0; i < navigationMenu.size(); i++) {
MenuItem menuItem = navigationMenu.getItem(i);
if (menuItem.isVisible()) {
menuItemsLayout.addView(createFabMenuItem(menuItem));
}
}
animateFabMenuItemsIn();
}
示例5: disableEnableMenuItem
import android.view.MenuItem; //導入方法依賴的package包/類
private void disableEnableMenuItem(
Menu menu, int id, boolean visible, boolean enabled, boolean managed) {
for (int i = 0; i < menu.size(); ++i) {
MenuItem item = menu.getItem(i);
if (item.getItemId() == id && item.isVisible()) {
item.setVisible(visible);
item.setEnabled(enabled);
if (managed) {
item.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
} else {
item.setIcon(null);
}
}
}
}
示例6: refreshMenus
import android.view.MenuItem; //導入方法依賴的package包/類
private void refreshMenus() {
menuContainer.removeAllViews();
for (int i = 0; i < menu.size(); i++) {
MenuItem menuItem = menu.getItem(i);
if (menuItem.isVisible()) {
View itemView = createItemView(i, menuItem);
menuContainer.addView(itemView);
}
}
}
示例7: toggleMenuItemVisibility
import android.view.MenuItem; //導入方法依賴的package包/類
private void toggleMenuItemVisibility(final MenuItem item, final boolean visible) {
if (visible) {
if (!item.isVisible()) {
item.setVisible(true);
}
} else if (item.isVisible()) {
item.setVisible(false);
}
}
示例8: onPrepareOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean hasChanges = false;
if (getCurrentFragment() instanceof ChatFragment) {
ChatFragment fragment = ((ChatFragment) getCurrentFragment());
ServerConnectionApi api = ((ServerConnectionApi) fragment.getConnectionInfo().getApiInstance());
boolean connected = fragment.getConnectionInfo().isConnected();
boolean wasConnected = !menu.findItem(R.id.action_reconnect).isVisible();
if (connected != wasConnected) {
if (connected) {
menu.findItem(R.id.action_reconnect).setVisible(false);
menu.findItem(R.id.action_close).setVisible(false);
menu.findItem(R.id.action_disconnect).setVisible(true);
menu.findItem(R.id.action_disconnect_and_close).setVisible(true);
} else {
menu.findItem(R.id.action_reconnect).setVisible(true);
menu.findItem(R.id.action_close).setVisible(true);
menu.findItem(R.id.action_disconnect).setVisible(false);
menu.findItem(R.id.action_disconnect_and_close).setVisible(false);
}
hasChanges = true;
}
if (fragment.getSendMessageHelper().hasSendMessageTextSelection() !=
menu.findItem(R.id.action_format).isVisible()) {
menu.findItem(R.id.action_format).setVisible(fragment.getSendMessageHelper()
.hasSendMessageTextSelection());
hasChanges = true;
}
MenuItem partItem = menu.findItem(R.id.action_part_channel);
if (fragment.getCurrentChannel() == null) {
if (partItem.isVisible())
hasChanges = true;
partItem.setVisible(false);
} else if (fragment.getCurrentChannel().length() > 0 && !api.getServerConnectionData()
.getSupportList().getSupportedChannelTypes().contains(fragment.getCurrentChannel().charAt(0))) {
if (partItem.isVisible() || !partItem.getTitle().equals(getString(R.string.action_close_direct)))
hasChanges = true;
partItem.setVisible(true);
partItem.setTitle(R.string.action_close_direct);
} else {
if (partItem.isVisible() || !partItem.getTitle().equals(getString(R.string.action_part_channel)))
hasChanges = true;
partItem.setVisible(true);
partItem.setTitle(R.string.action_part_channel);
}
}
return super.onPrepareOptionsMenu(menu) | hasChanges;
}
示例9: createAdapterItems
import android.view.MenuItem; //導入方法依賴的package包/類
private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor,
int itemTextColor, int itemBackground,
int tintColor) {
List<BottomSheetItem> items = new ArrayList<>();
mTitles = 0;
boolean addedSubMenu = false;
for (int i = 0; i < mMenu.size(); i++) {
MenuItem item = mMenu.getItem(i);
if (item.isVisible()) {
if (item.hasSubMenu()) {
SubMenu subMenu = item.getSubMenu();
if (i != 0 && addedSubMenu) {
if (mMode == BottomSheetBuilder.MODE_GRID) {
throw new IllegalArgumentException("MODE_GRID can't have submenus." +
" Use MODE_LIST instead");
}
items.add(new BottomSheetDivider(dividerBackground));
}
CharSequence title = item.getTitle();
if (title != null && !title.equals("")) {
items.add(new BottomSheetHeader(title.toString(), titleTextColor));
mTitles++;
}
for (int j = 0; j < subMenu.size(); j++) {
MenuItem subItem = subMenu.getItem(j);
if (subItem.isVisible()) {
items.add(new BottomSheetMenuItem(subItem,itemTextColor, itemBackground, tintColor));
addedSubMenu = true;
}
}
} else {
items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor));
}
}
}
return items;
}
示例10: onPrepareOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
final MenuItem itemUpdate = menu.findItem(R.id.action_update);
final MenuItem itemSortEntries = menu.findItem(R.id.action_sort_entries);
final MenuItem itemExportAsOPML = menu.findItem(R.id.action_opml_export);
final MenuItem itemFilter = menu.findItem(R.id.action_filter_by_categories);
final MenuItem itemSearch = menu.findItem(R.id.action_search);
final MenuItem itemSettings = menu.findItem(R.id.action_settings);
final MenuItem itemFilterSubs = menu.findItem(R.id.action_filter_subscriptions_by_category);
final boolean isSearchViewNotExpanded = !isSearchViewExpanded();
if (isNotInInitialSetup()) {
if (getLoadCurrentFeedFragment().isAdded()) {
toggleMenuItemVisibility(itemSearch, false);
toggleMenuItemVisibility(itemSortEntries, false);
toggleMenuItemVisibility(itemFilterSubs, false);
toggleMenuItemVisibility(itemExportAsOPML, false);
} else if (getCurrentFeedFragment().isAdded()) {
toggleMenuItemVisibility(itemSortEntries, false);
toggleMenuItemVisibility(itemFilterSubs, false);
toggleMenuItemVisibility(itemExportAsOPML, false);
if (isSearchViewNotExpanded) {
toggleMenuItemVisibility(itemUpdate, true);
toggleMenuItemVisibility(itemSearch, true);
}
if (CurrentFeed.isRSSFeed() && CurrentFeed.isCategoriesAvailable() &&
isSearchViewNotExpanded) {
toggleMenuItemVisibility(itemFilter, true);
}
} else if (getFeedSubscriptionsFragment().isAdded()) {
toggleMenuItemVisibility(itemUpdate, false);
toggleMenuItemVisibility(itemSortEntries, false);
toggleMenuItemVisibility(itemFilter, false);
if (isSearchViewNotExpanded) {
toggleMenuItemVisibility(itemFilterSubs, true);
toggleMenuItemVisibility(itemExportAsOPML, true);
toggleMenuItemVisibility(itemSearch, true);
}
} else if (getSavedEntriesFragment().isAdded()) {
toggleMenuItemVisibility(itemUpdate, false);
toggleMenuItemVisibility(itemFilter, false);
toggleMenuItemVisibility(itemFilterSubs, false);
toggleMenuItemVisibility(itemExportAsOPML, false);
if (isSearchViewNotExpanded) {
toggleMenuItemVisibility(itemSortEntries, true);
toggleMenuItemVisibility(itemSearch, true);
}
final MenuItem itemSortOrderAsc =
menu.findItem(R.id.action_sort_order_ascending);
final MenuItem itemSortOrderDesc =
menu.findItem(R.id.action_sort_order_descending);
if (getSavedEntriesFragment().getSortOrder() == SORT_ORDER_DESCENDING) {
itemSortOrderDesc.setEnabled(false);
if (!itemSortOrderAsc.isVisible()) {
itemSortOrderAsc.setVisible(true);
}
} else {
itemSortOrderAsc.setEnabled(false);
if (!itemSortOrderDesc.isVisible()) {
itemSortOrderDesc.setVisible(true);
}
}
}
if (isSearchViewNotExpanded) {
toggleMenuItemVisibility(itemSettings, true);
}
}
return true;
}