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

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

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

Toolbar.inflateMenu介绍

暂无

代码示例

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  if (container == null) {
    // Currently in a layout without a container, so no reason to create our view.
    return null;
  }
  restorePreferences();
  mStudyOptionsView = inflater.inflate(R.layout.studyoptions_fragment, container, false);
  mFragmented = getActivity().getClass() != StudyOptionsActivity.class;
  initAllContentViews();
  if (getArguments() != null) {
    mLoadWithDeckOptions = getArguments().getBoolean("withDeckOptions");
  }
  mToolbar = (Toolbar) mStudyOptionsView.findViewById(R.id.studyOptionsToolbar);
  mToolbar.inflateMenu(R.menu.study_options_fragment);
  if (mToolbar != null) {
    configureToolbar();
  }
  refreshInterface(true);
  return mStudyOptionsView;
}

代码示例来源:origin: chrisbanes/PhotoView

setContentView(R.layout.activity_rotation_sample);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.inflateMenu(R.menu.rotation);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override

代码示例来源:origin: KeepSafe/TapTargetView

toolbar.inflateMenu(R.menu.menu_main);
toolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.ic_arrow_back_white_24dp));

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

mToolbar.setTitle(mDialogTitle);
mToolbar.inflateMenu(R.menu.tags_dialog_menu);

代码示例来源:origin: chrisbanes/PhotoView

toolbar.inflateMenu(R.menu.main_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override

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

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_log).setChecked(true);
  toolbar.setTitle(R.string.action_log);
  toolbar.inflateMenu(R.menu.log);
  toolbar.setOnMenuItemClickListener(this);
}

代码示例来源: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: 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: ongakuer/PhotoDraweeView

private void initToolbar() {
  Toolbar toolbar = findViewById(R.id.toolbar);
  toolbar.inflateMenu(R.menu.single);
  toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
    @Override public boolean onMenuItemClick(MenuItem menuItem) {

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

toolbar.setNavigationOnClickListener(v -> onBackPressed());
toolbar.setOnMenuItemClickListener(fragment);
toolbar.inflateMenu(R.menu.custom_config);

代码示例来源: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: linkedin/shaky-android

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  Toolbar toolbar = (Toolbar) view.findViewById(R.id.shaky_toolbar);
  EditText messageEditText = (EditText) view.findViewById(R.id.shaky_form_message);
  ImageView attachmentImageView = (ImageView) view.findViewById(R.id.shaky_form_attachment);
  Uri screenshotUri = getArguments().getParcelable(KEY_SCREENSHOT_URI);
  String title = getArguments().getString(KEY_TITLE);
  toolbar.setTitle(title);
  toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
  toolbar.setNavigationOnClickListener(createNavigationClickListener());
  toolbar.inflateMenu(R.menu.shaky_feedback_activity_actions);
  toolbar.setOnMenuItemClickListener(createMenuClickListener(messageEditText));
  String hint = getArguments().getString(KEY_HINT);
  messageEditText.setHint(hint);
  messageEditText.requestFocus();
  attachmentImageView.setImageURI(screenshotUri);
  attachmentImageView.setOnClickListener(createNavigationClickListener());
}

代码示例来源:origin: raphaelbussa/HeaderView

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Toolbar toolbar = findViewById(R.id.toolbar);
  toolbar.setTitle(getString(R.string.app_name));
  toolbar.inflateMenu(R.menu.menu_main);
  toolbar.setOnMenuItemClickListener(this);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
  }
  findViewById(R.id.normal_drawer).setOnClickListener(v -> startActivity(new Intent(MainActivity.this, NormalHeaderActivity.class)));
  findViewById(R.id.compact_drawer).setOnClickListener(v -> startActivity(new Intent(MainActivity.this, CompactHeaderActivity.class)));
}

代码示例来源: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: cbeyls/fosdem-companion-android

final Context context = toolbar.getContext();
toolbar.inflateMenu(R.menu.room_image_dialog);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override

代码示例来源:origin: Commit451/AdapterLayout

toolbar.inflateMenu(R.menu.main);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override

代码示例来源:origin: IvBaranov/RxBluetooth

toolbar.inflateMenu(R.menu.main_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
 @Override public boolean onMenuItemClick(MenuItem item) {

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

toolbar.inflateMenu(R.menu.feed_items);
toolbar.setNavigationIcon(ContextCompat.getDrawable(activity.getApplicationContext(),
    R.drawable.ic_arrow_back_white_24dp));

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

toolbar.inflateMenu(R.menu.detail_torrent);
toolbar.setNavigationIcon(ContextCompat.getDrawable(activity.getApplicationContext(),
                          R.drawable.ic_arrow_back_white_24dp));

代码示例来源:origin: raphaelbussa/HeaderView

Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.app_name));
toolbar.inflateMenu(R.menu.menu_main);
toolbar.setNavigationOnClickListener(view -> {
  if (drawerLayout != null && !drawerLayout.isDrawerOpen(GravityCompat.START)) {

相关文章