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

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

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

Toolbar.setOnMenuItemClickListener介绍

暂无

代码示例

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

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

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

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

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

toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override
  public boolean onMenuItemClick(MenuItem item) {

代码示例来源: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) {
      switch (menuItem.getItemId()) {

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

toolbar.setNavigationIcon(drawable);
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: h4h13/RetroMusicPlayer

final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context,
    menuWidgetColor, currentClickListener, toolbar);
toolbar.setOnMenuItemClickListener(newClickListener);

代码示例来源:origin: cbeyls/fosdem-companion-android

toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override
  public boolean onMenuItemClick(MenuItem item) {

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

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

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

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

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

toolbar.setNavigationOnClickListener((View view) -> onBackPressed());
toolbar.getNavigationIcon();
toolbar.setOnMenuItemClickListener(this::onOptionsItemSelected);

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

R.drawable.ic_arrow_back_white_24dp));
toolbar.setNavigationOnClickListener((View view) -> onBackPressed());
toolbar.setOnMenuItemClickListener(this::onOptionsItemSelected);

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

R.drawable.ic_arrow_back_white_24dp));
toolbar.setNavigationOnClickListener((View view) -> onBackPressed());
toolbar.setOnMenuItemClickListener(this::onOptionsItemSelected);

相关文章