androidx.appcompat.widget.Toolbar.getMenu()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中androidx.appcompat.widget.Toolbar.getMenu()方法的一些代码示例,展示了Toolbar.getMenu()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.getMenu()方法的具体详情如下:
包路径:androidx.appcompat.widget.Toolbar
类名称:Toolbar
方法名:getMenu

Toolbar.getMenu介绍

暂无

代码示例

代码示例来源:origin: ankidroid/Anki-Android

public void configureToolbar() {
  mToolbar.setOnMenuItemClickListener(this);
  Menu menu = mToolbar.getMenu();

代码示例来源:origin: ankidroid/Anki-Android

MenuItem mToolbarAddItem = mToolbar.getMenu().findItem(R.id.tags_dialog_action_add);
mToolbarAddItem.setOnMenuItemClickListener(menuItem -> {
  String query = mToolbarSearchView.getQuery().toString();
});
mToolbarSearchItem = mToolbar.getMenu().findItem(R.id.tags_dialog_action_filter);
mToolbarSearchView = (SearchView) mToolbarSearchItem.getActionView();
MenuItem checkAllItem = mToolbar.getMenu().findItem(R.id.tags_dialog_action_select_all);
checkAllItem.setOnMenuItemClickListener(menuItem -> {
  boolean changed = false;

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

@Nullable
@Override
public final Menu getToolbarMenu() {
  Toolbar[] toolbars = getToolbars();
  if (toolbars != null) {
    Toolbar toolbar = toolbars.length > 1 ? toolbars[TabSwitcher.SECONDARY_TOOLBAR_INDEX] :
        toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX];
    return toolbar.getMenu();
  }
  return null;
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

@NonNull
@Override
public View onInflateView(@NonNull final LayoutInflater inflater,
             @Nullable final ViewGroup parent, final int viewType) {
  View view;
  if (viewType == 0) {
    view = inflater.inflate(R.layout.tab_text_view, parent, false);
  } else if (viewType == 1) {
    view = inflater.inflate(R.layout.tab_edit_text, parent, false);
  } else {
    view = inflater.inflate(R.layout.tab_list_view, parent, false);
  }
  Toolbar toolbar = view.findViewById(R.id.toolbar);
  toolbar.inflateMenu(R.menu.tab);
  toolbar.setOnMenuItemClickListener(createToolbarMenuListener());
  Menu menu = toolbar.getMenu();
  TabSwitcher.setupWithMenu(tabSwitcher, menu, createTabSwitcherButtonListener());
  return view;
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_rules).setChecked(true);
  toolbar.inflateMenu(R.menu.rules);
  toolbar.setTitle(R.string.action_rules);
  toolbar.setOnMenuItemClickListener(this);
  toolbar.getMenu().findItem(R.id.action_change_type).setTitle(Rule.getTypeById(currentType));
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  menu = ((NavigationView) getActivity().findViewById(R.id.nav_view)).getMenu();
  toolbar = getActivity().findViewById(R.id.toolbar);
  toolbar.getMenu().clear();
  checkStatus();
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public boolean onMenuItemClick(MenuItem item) {
  int id = item.getItemId();
  if (id == R.id.action_change_type) {
    if (currentType == Rule.TYPE_HOSTS) {
      currentType = Rule.TYPE_DNAMASQ;
    } else if (currentType == Rule.TYPE_DNAMASQ) {
      currentType = Rule.TYPE_HOSTS;
    }
    toolbar.getMenu().findItem(R.id.action_change_type).setTitle(Rule.getTypeById(currentType));
    adapter.notifyDataSetChanged();
  }
  if (id == R.id.action_reload) {
    if (!Daedalus.getPrefs().getBoolean("settings_allow_dynamic_rule_reload", false)) {
      Snackbar.make(getView(), R.string.notice_check_dynamic_rule_reload, Snackbar.LENGTH_SHORT).show();
    } else {
      Daedalus.setRulesChanged();
    }
  }
  return true;
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

/**
 * Inflates the menu of the toolbar, which is shown, when the tab switcher is shown.
 */
private void inflateToolbarMenu() {
  Toolbar[] toolbars = getToolbars();
  int menuId = getModel().getToolbarMenuId();
  if (toolbars != null && menuId != -1) {
    Toolbar toolbar = toolbars.length > 1 ? toolbars[TabSwitcher.SECONDARY_TOOLBAR_INDEX] :
        toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX];
    Menu previousMenu = toolbar.getMenu();
    if (previousMenu != null) {
      previousMenu.clear();
    }
    toolbar.inflateMenu(menuId);
    toolbar.setOnMenuItemClickListener(getModel().getToolbarMenuItemListener());
  }
}

代码示例来源:origin: h4h13/RetroMusicPlayer

menu = toolbar.getMenu();

代码示例来源:origin: AndroidDeveloperLB/MaterialPreferenceLibrary

private void handleActionBarMenu() {
  getToolbar().inflateMenu(R.menu.activity_main);
  final OnMenuItemClickListener onMenuItemClickListener = new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(final MenuItem item) {
      String url = null;
      switch (item.getItemId()) {
        case R.id.menuItem_all_my_apps:
          url = "https://play.google.com/store/apps/developer?id=AndroidDeveloperLB";
          break;
        case R.id.menuItem_all_my_repositories:
          url = "https://github.com/AndroidDeveloperLB";
          break;
        case R.id.menuItem_current_repository_website:
          url = "https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary";
          break;
      }
      if (url == null)
        return true;
      final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
      intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
      startActivity(intent);
      return true;
    }
  };
  setOnMenuItemClickListenerRecursive(getToolbar().getMenu(), onMenuItemClickListener);
}

代码示例来源:origin: proninyaroslav/libretorrent

prepareOptionsMenu(toolbar.getMenu());
else
  activity.invalidateOptionsMenu();

相关文章