android.support.v7.widget.Toolbar.setOnMenuItemClickListener()方法的使用及代码示例

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

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

Toolbar.setOnMenuItemClickListener介绍

暂无

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onCreateOptionsMenu(Menu menu) {
 Toolbar tb=(Toolbar)findViewById(R.id.toolbar);
 tb.inflateMenu(R.menu.actions);
 tb.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override
  public boolean onMenuItemClick(MenuItem item) {
   return(onOptionsItemSelected(item));
  }
 });
 return(super.onCreateOptionsMenu(menu));
}

代码示例来源:origin: yanzhenjie/NoHttp

@Override
void setActionBar(Toolbar actionBar) {
  this.mActionBar = actionBar;
  if (mActionBar != null) {
    mActionBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        if (mMenuItemSelectedListener != null) {
          mMenuItemSelectedListener.onMenuClick(item);
        }
        return true;
      }
    });
    mActionBar.setNavigationOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (mMenuItemSelectedListener != null) {
          mMenuItemSelectedListener.onHomeClick();
        }
      }
    });
    mActionBarIcon = mActionBar.getNavigationIcon();
  }
}

代码示例来源:origin: android-cjj/Android-MaterialRefreshLayout

private void initsToolbar() {
  Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  toolbar.setOnMenuItemClickListener(onMenuItemClick);
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void initToolbar(Toolbar toolbar) {
  if (DEBUG) Log.d(TAG, "initToolbar() called with: toolbar = [" + toolbar + "]");
  toolbar.setTitle(R.string.download_dialog_title);
  toolbar.setNavigationIcon(ThemeHelper.isLightThemeSelected(getActivity()) ? R.drawable.ic_arrow_back_black_24dp : R.drawable.ic_arrow_back_white_24dp);
  toolbar.inflateMenu(R.menu.dialog_url);
  toolbar.setNavigationOnClickListener(v -> getDialog().dismiss());
  toolbar.setOnMenuItemClickListener(item -> {
    if (item.getItemId() == R.id.okay) {
      prepareSelectedDownload();
      return true;
    }
    return false;
  });
}

代码示例来源:origin: Cleveroad/AdaptiveTableLayout

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

代码示例来源:origin: square/spoon

@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 if (!getIntent().hasExtra(KEY_AMOUNT_CENTS)) {
  throw new IllegalStateException("Missing amount extra");
 }
 amount = getIntent().getLongExtra(KEY_AMOUNT_CENTS, -1);
 if (amount < 100) {
  throw new IllegalArgumentException("Invalid amount: " + amount);
 }
 setContentView(R.layout.recipeint);
 ButterKnife.bind(this);
 toolbar.setTitle(getString(R.string.send_amount, Moneys.formatCents(amount)));
 toolbar.inflateMenu(R.menu.recipient);
 sendMenuItem = toolbar.getMenu().findItem(R.id.recipient_send);
 sendMenuItem.setEnabled(false);
 toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
  @Override public boolean onMenuItemClick(MenuItem item) {
   switch (item.getItemId()) {
    case R.id.recipient_send:
     onSendClicked();
     return true;
    default:
     throw new IllegalStateException("Unknown menu item: " + item);
   }
  }
 });
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

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

代码示例来源:origin: seven332/EhViewer

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  if (mToolbar != null) {
    if (mTempTitle != null) {
      mToolbar.setTitle(mTempTitle);
      mTempTitle = null;
    }
    int menuResId = getMenuResId();
    if (menuResId != 0) {
      mToolbar.inflateMenu(menuResId);
      mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
          return ToolbarScene.this.onMenuItemClick(item);
        }
      });
      onMenuCreated(mToolbar.getMenu());
    }
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        onNavigationClick();
      }
    });
  }
}

代码示例来源:origin: pinguo-zhouwei/MZBannerView

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.home_activity);
  StatusBarUtils.setColor(this,getResources().getColor(R.color.colorPrimary),0);
  mToolbar = (Toolbar) findViewById(R.id.tool_bar);
  mToolbar.inflateMenu(R.menu.setting);
  mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      if(item.getItemId() ==R.id.banner_mode){
        switchBannerMode();
      }else if(item.getItemId() == R.id.viewPager_mode){
        switchViewPagerMode();
      }else if(item.getItemId() == R.id.remote_mode){
        switchRemoteMode();
      }else if(item.getItemId() == R.id.mz_mode_not_cover){
        switchMZModeNotCover();
      }
      return true;
    }
  });
  Fragment fragment = MZModeBannerFragment.newInstance();
  getSupportFragmentManager().beginTransaction().add(R.id.home_container,fragment).commit();
}

代码示例来源:origin: seven332/EhViewer

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

代码示例来源:origin: yanzhenjie/NoHttp

@Override
void setActionBar(Toolbar actionBar) {
  this.mActionBar = actionBar;
  Activity activity = getSource();
  if (mActionBar != null) {
    setTitle(activity.getTitle());
    mActionBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        if (mMenuItemSelectedListener != null) {
          mMenuItemSelectedListener.onMenuClick(item);
        }
        return true;
      }
    });
    mActionBar.setNavigationOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (mMenuItemSelectedListener != null) {
          mMenuItemSelectedListener.onHomeClick();
        }
      }
    });
    mActionBarIcon = mActionBar.getNavigationIcon();
  }
}

代码示例来源:origin: seven332/EhViewer

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

代码示例来源:origin: qiujuer/Genius-Android

private void initToolbar() {
  // ToolBar
  RipAnimDrawable ripAnim = new RipAnimDrawable();
  ripAnim.setColor(getResources().getColor(R.color.cyan_600));
  ripAnim.setFluCount(0, 0, 0, 36);
  Toolbar toolbar = (Toolbar) findViewById(R.id.title);
  toolbar.setBackgroundDrawable(ripAnim);
  toolbar.setTitle(getTitle());
  toolbar.inflateMenu(R.menu.menu_main);
  toolbar.setOnMenuItemClickListener(this);
}

代码示例来源:origin: seven332/EhViewer

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

代码示例来源:origin: xinghongfei/LookLook

IMainPresenter.getBackground();
toolbar.setOnMenuItemClickListener(onMenuItemClick);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  animateToolbar();

代码示例来源:origin: TakWolf/CNode-Material-Design

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_modify_topic_sign);
  ButterKnife.bind(this);
  toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
  toolbar.inflateMenu(R.menu.modify_topic_sign);
  toolbar.setOnMenuItemClickListener(this);
  edtContent.setText(SettingShared.getTopicSignContent(this));
  edtContent.setSelection(edtContent.length());
}

代码示例来源:origin: TakWolf/CNode-Material-Design

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_notification_compat);
  ButterKnife.bind(this);
  toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
  toolbar.inflateMenu(R.menu.notification);
  toolbar.setOnMenuItemClickListener(this);
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(webNotification));
  notificationPresenter = new NotificationPresenter(this, this);
  refreshLayout.setColorSchemeResources(R.color.color_accent);
  refreshLayout.setOnRefreshListener(this);
  refreshLayout.setRefreshing(true);
  onRefresh();
}

代码示例来源:origin: TakWolf/CNode-Material-Design

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_notification);
  ButterKnife.bind(this);
  toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
  toolbar.inflateMenu(R.menu.notification);
  toolbar.setOnMenuItemClickListener(this);
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
  recyclerView.setLayoutManager(new LinearLayoutManager(this));
  adapter = new MessageListAdapter(this);
  recyclerView.setAdapter(adapter);
  notificationPresenter = new NotificationPresenter(this, this);
  refreshLayout.setColorSchemeResources(R.color.color_accent);
  refreshLayout.setOnRefreshListener(this);
  refreshLayout.setRefreshing(true);
  onRefresh();
}

代码示例来源:origin: TakWolf/CNode-Material-Design

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_create_topic);
  ButterKnife.bind(this);
  toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
  toolbar.inflateMenu(R.menu.create_topic);
  toolbar.setOnMenuItemClickListener(this);
  spnTab.setAdapter(new TabSpinnerAdapter(this, Tab.getPublishableTabList()));
  progressDialog = ProgressDialog.createWithAutoTheme(this);
  progressDialog.setCancelable(false);
  // 创建EditorBar
  new EditorBarViewHolder(this, editorBar, edtContent);
  // 载入草稿
  if (SettingShared.isEnableTopicDraft(this)) {
    spnTab.setSelection(TopicShared.getDraftTabPosition(this));
    edtContent.setText(TopicShared.getDraftContent(this));
    edtContent.setSelection(edtContent.length());
    edtTitle.setText(TopicShared.getDraftTitle(this));
    edtTitle.setSelection(edtTitle.length()); // 这个必须最后调用
  }
  createTopicPresenter = new CreateTopicPresenter(this, this);
}

代码示例来源:origin: TakWolf/CNode-Material-Design

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_topic_compat);
  ButterKnife.bind(this);
  topicId = getIntent().getStringExtra(Navigator.TopicWithAutoCompat.EXTRA_TOPIC_ID);
  toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
  toolbar.inflateMenu(R.menu.topic);
  toolbar.setOnMenuItemClickListener(this);
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
  topicPresenter = new TopicPresenter(this, this);
  topicHeaderPresenter = new TopicHeaderPresenter(this, this);
  replyPresenter = new ReplyPresenter(this, this);
  createReplyView = CreateReplyDialog.createWithAutoTheme(this, topicId, this);
  webTopic.addOnScrollListener(new FloatingActionButtonBehaviorListener.ForWebView(fabReply));
  webTopic.setBridgeAndLoadPage(new TopicJavascriptInterface(this, createReplyView, topicHeaderPresenter, replyPresenter));
  refreshLayout.setColorSchemeResources(R.color.color_accent);
  refreshLayout.setOnRefreshListener(this);
  refreshLayout.setRefreshing(true);
  onRefresh();
}

相关文章

Toolbar类方法