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

x33g5p2x  于2022-01-26 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(114)

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

PopupMenu.getMenu介绍

暂无

代码示例

代码示例来源:origin: hidroh/materialistic

@Override
public PopupMenu setMenuItemTitle(@IdRes int itemResId, @StringRes int title) {
  mSupportPopupMenu.getMenu().findItem(itemResId).setTitle(title);
  return this;
}

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

PopupMenu popup = new PopupMenu(context, mOtherActions, Gravity.TOP);
mPopupMenu = popup;
popup.getMenuInflater().inflate(R.menu.scene_gallery_detail, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
  @Override

代码示例来源:origin: chrisk44/Hijacker

void showSortingPopup(View v){
    PopupMenu popup = new PopupMenu(getActivity(), v);

    popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
    popup.getMenu().add(0, SORT_NOSORT, 0, sort_texts[SORT_NOSORT]);
    popup.getMenu().add(0, SORT_ESSID, 1, sort_texts[SORT_ESSID]);
    popup.getMenu().add(0, SORT_BEACONS_FRAMES, 2, sort_texts[SORT_BEACONS_FRAMES]);
    popup.getMenu().add(0, SORT_DATA_FRAMES, 3, sort_texts[SORT_DATA_FRAMES]);
    popup.getMenu().add(0, SORT_PWR, 4, sort_texts[SORT_PWR]);
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
      public boolean onMenuItemClick(android.view.MenuItem item) {
        temp_sort = item.getItemId();
        sortSelectBtn.setText(sort_texts[temp_sort]);
        return true;
      }
    });
    popup.show();
  }
}

代码示例来源:origin: hidroh/materialistic

@Override
public PopupMenu setMenuItemVisible(@IdRes int itemResId, boolean visible) {
  mSupportPopupMenu.getMenu().findItem(itemResId).setVisible(visible);
  return this;
}

代码示例来源:origin: SecUSo/privacy-friendly-pedometer

public void showPopup(View v, Context c) {
  PopupMenu popup = new PopupMenu(c, v);
  MenuInflater inflater = popup.getMenuInflater();
  inflater.inflate(R.menu.menu_card_walking_mode, popup.getMenu());
  popup.getMenu().findItem(R.id.menu_set_active).setChecked(isActive);
  popup.setOnMenuItemClickListener(this);
  popup.show();
}

代码示例来源:origin: willowtreeapps/Hyperion-Android

private void showMenu(View anchor) {
  final Context context = anchor.getContext();
  if (popupMenu != null) {
    popupMenu.dismiss();
  }
  popupMenu = new PopupMenu(context, anchor);
  popupMenu.inflate(R.menu.hgc_menu_options);
  final Menu menu = popupMenu.getMenu();
  final MenuItem areHapticsEnabledItem = menu.findItem(R.id.menu_item_use_haptics);
  areHapticsEnabledItem.setChecked(detector.areHapticsEnabled());
  areHapticsEnabledItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      boolean areHapticsEnabled = !item.isChecked();
      item.setChecked(areHapticsEnabled);
      detector.setHapticsEnabled(areHapticsEnabled);
      return true;
    }
  });
  popupMenu.show();
}

代码示例来源:origin: SecUSo/privacy-friendly-pedometer

public void showPopup(View v, Context c) {
  PopupMenu popup = new PopupMenu(c, v);
  MenuInflater inflater = popup.getMenuInflater();
  inflater.inflate(R.menu.menu_card_activity_summary, popup.getMenu());
  popup.setOnMenuItemClickListener(this);
  if (mItemClickListener != null) {
    mItemClickListener.setActivityChartDataTypeChecked(popup.getMenu());
  }
  popup.show();
}

代码示例来源:origin: 0xZhangKe/ShiZhong

@OnClick(R.id.et_period_type)
public void onPeriodTypeClick(View view) {
  PopupMenu popupMenu = new PopupMenu(this, view);
  popupMenu.getMenu().add(0, 0, 0, "天");
  popupMenu.getMenu().add(0, 1, 0, "周");
  popupMenu.getMenu().add(0, 2, 0, "月");
  popupMenu.setOnMenuItemClickListener(item -> {
    etPeriodType.setText(item.getTitle());
    this.periodType = item.getItemId();
    updatePeriodTarget();
    return true;
  });
  popupMenu.show();
}

代码示例来源:origin: SecUSo/privacy-friendly-pedometer

public void showPopup(View v, Context c) {
  PopupMenu popup = new PopupMenu(c, v);
  MenuInflater inflater = popup.getMenuInflater();
  inflater.inflate(R.menu.menu_card_training_session, popup.getMenu());
  popup.setOnMenuItemClickListener(this);
  popup.show();
}

代码示例来源:origin: SecUSo/privacy-friendly-pedometer

public void showPopup(View v, Context c) {
  PopupMenu popup = new PopupMenu(c, v);
  if (mItemClickListener != null) {
    mItemClickListener.inflateWalkingModeMenu(popup.getMenu());
  }
  popup.setOnMenuItemClickListener(this);
  popup.show();
}

代码示例来源:origin: owntracks/android

private void showPopupMenu(View v) {
  PopupMenu popupMenu = new PopupMenu(this, v, Gravity.START); //new PopupMenu(this, v);
  popupMenu.getMenuInflater().inflate(R.menu.menu_popup_contacts, popupMenu.getMenu());
  popupMenu.setOnMenuItemClickListener(this);
  if (preferences.getModeId() == MessageProcessorEndpointHttp.MODE_ID)
    popupMenu.getMenu().removeItem(R.id.menu_clear);
  popupMenu.show();
}

代码示例来源:origin: anyaudio/anyaudio-android-app

private void showExploreItemPopUpMenu(View view, final String v_id, final String youtubeId, final String title, final String artist) {
  PopupMenu popup = new PopupMenu(this, view);
  popup.getMenuInflater().inflate(R.menu.explore_card_popup, popup.getMenu());
  popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      onAddToQueue(v_id, youtubeId, title, artist);
      ToastMaker.getInstance(AnyAudioActivity.this).toast("\"" + title + "\" Added To Queue");
      return true;
    }
  });
  popup.show();
}

代码示例来源:origin: Pixplicity/letterpress

private void showPopupMenu(View anchorView) {
  PopupMenu popup = new PopupMenu(MainActivity.this, anchorView);
  popup.getMenuInflater().inflate(R.menu.menu, popup.getMenu());
  popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    public boolean onMenuItemClick(MenuItem item) {
      // ...
      return true;
    }
  });
  // Apply custom font to popup menu
  FontUtil.applyTypeface(popup.getMenu(), mTypeface);
  popup.show();
}

代码示例来源:origin: SecUSo/privacy-friendly-pedometer

public void showPopup(View v, Context c) {
  PopupMenu popup = new PopupMenu(c, v);
  MenuInflater inflater = popup.getMenuInflater();
  inflater.inflate(R.menu.menu_card_motivation_text, popup.getMenu());
  popup.setOnMenuItemClickListener(this);
  popup.show();
}

代码示例来源:origin: burgessjp/GanHuoIO

@Override
  public void onClick(View v) {
    PopupMenu popupMenu = new PopupMenu(SearchActivity.this, mIvSelectCate);
    popupMenu.getMenuInflater()
        .inflate(R.menu.menu_category, popupMenu.getMenu());
    popupMenu.show();
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        mKeywordText.setHint(item.getTitle());
        return true;
      }
    });
  }
});

代码示例来源:origin: brianwernick/RecyclerExt

/**
 * Shows the menu specified with the <code>menuResourceId</code> starting
 * at the <code>anchor</code>
 *
 * @param anchor The view to show the popup menu from
 * @param menuResourceId The resource id for the menu to show
 */
protected void showMenu(@NonNull View anchor, @MenuRes int menuResourceId) {
  PopupMenu menu = new PopupMenu(anchor.getContext(), anchor);
  MenuInflater inflater = menu.getMenuInflater();
  inflater.inflate(menuResourceId, menu.getMenu());
  onPreparePopupMenu(menu.getMenu());
  menu.setOnMenuItemClickListener(this);
  menu.show();
}

代码示例来源:origin: yydcdut/RxMarkdown

@Override
public void onClick(View v) {
  PopupMenu popup = new PopupMenu(getContext(), mTargetImageView);
  MenuInflater inflater = popup.getMenuInflater();
  inflater.inflate(R.menu.menu_popup, popup.getMenu());
  popup.setOnMenuItemClickListener(this);
  popup.show();
}

代码示例来源:origin: anyaudio/anyaudio-android-app

public void showAutoPlayItemPopUp(View view, final String v_id, final String youtubeId, final String title, final String artist) {
  PopupMenu popup = new PopupMenu(this, view);
  popup.getMenuInflater().inflate(R.menu.autoplay_item_popup, popup.getMenu());
  popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      if(item.getItemId()==R.id.addAutoPlayToQueue){
        onAddToQueue(v_id, youtubeId, title, artist);
      }else{
        //download item
        showDownloadDialog(v_id, title,getImageUrl(youtubeId), artist);
      }
      return true;
    }
  });
  popup.show();
}

代码示例来源:origin: niugao/RecyclerListTreeView

@Override
  public void onClick(View v) {
    int nodePlaneIndex = getAdapterPosition();
    ListTree.TreeNode node = tree.getNodeByPlaneIndex(nodePlaneIndex);
    currentNode=node;
    PopupMenu popup = new PopupMenu(v.getContext(), v);
    popup.setOnMenuItemClickListener(itemMenuClickListener);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.menu_item, popup.getMenu());
    popup.show();
  }
});

代码示例来源:origin: fasteque/rgb-tool

private void showPopupMenu(View view) {
    final int colorId = (int) view.getTag();

    PopupMenu popup = new PopupMenu(view.getContext(), view);
    popup.getMenuInflater().inflate(R.menu.color_popup, popup.getMenu());
    popup.setOnMenuItemClickListener(menuItem -> {
      switch (menuItem.getItemId()) {
        case R.id.menu_remove:
          EventBus.getDefault().post(new ColorDeleteEvent(colorId));
          return true;
        case R.id.menu_share:
          EventBus.getDefault().post(new ColorShareEvent(colorId));
          return true;
      }
      return false;
    });

    popup.show();
  }
}

相关文章