本文整理汇总了Java中android.widget.PopupMenu.setOnMenuItemClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java PopupMenu.setOnMenuItemClickListener方法的具体用法?Java PopupMenu.setOnMenuItemClickListener怎么用?Java PopupMenu.setOnMenuItemClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.PopupMenu
的用法示例。
在下文中一共展示了PopupMenu.setOnMenuItemClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: popFilterMenu
import android.widget.PopupMenu; //导入方法依赖的package包/类
public void popFilterMenu(View rootview) {
int style = ResHelper.getStyleRes(getContext(), "BBS_PopupMenu");
Context wrapper = new ContextThemeWrapper(getContext(), style);
//Creating the instance of PopupMenu
PopupMenu popup = new PopupMenu(wrapper, rootview);
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(PageForumThreadDetail.getMenuRes(getContext(), "bbs_popup_forumthread"), popup.getMenu());
//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
//only one menu item.
if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebycomment")) {
orderType = ThreadListOrderType.LAST_POST;
performPullingDown(true);
} else if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebypost")) {
orderType = ThreadListOrderType.CREATE_ON;
performPullingDown(true);
}
return true;
}
});
popup.show();
}
示例2: showPopupMenu
import android.widget.PopupMenu; //导入方法依赖的package包/类
/**
* Show a {@link PopupMenu}.
*
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
* needs to be the tag of a native view (shadow views can not be anchors)
* @param items the menu items as an array of strings
* @param success will be called with the position of the selected item as the first argument, or
* no arguments if the menu is dismissed
*/
public void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
UiThreadUtil.assertOnUiThread();
View anchor = mTagsToViews.get(reactTag);
if (anchor == null) {
throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
}
PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);
Menu menu = popupMenu.getMenu();
for (int i = 0; i < items.size(); i++) {
menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
}
PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
popupMenu.setOnMenuItemClickListener(handler);
popupMenu.setOnDismissListener(handler);
popupMenu.show();
}
示例3: showPopup
import android.widget.PopupMenu; //导入方法依赖的package包/类
private void showPopup() {
PopupMenu popup = new PopupMenu(getActivity(), btn_more);
//Inflating the Popup using xml file
popup.getMenuInflater()
.inflate(R.menu.share_menu, popup.getMenu());
//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_send:
initShare(1);
break;
case R.id.menu_receive:
initShare(0);
break;
}
return true;
}
});
popup.show();
}
示例4: onBlockMenuClick
import android.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public void onBlockMenuClick(final View view, final StoredBlock block) {
final PopupMenu popupMenu = new PopupMenu(activity, view);
popupMenu.inflate(R.menu.blocks_context);
popupMenu.getMenu().findItem(R.id.blocks_context_browse).setVisible(Constants.ENABLE_BROWSE);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(final MenuItem item) {
switch (item.getItemId()) {
case R.id.blocks_context_browse:
final String blockHash = block.getHeader().getHashAsString();
final Uri blockExplorerUri = config.getBlockExplorer();
log.info("Viewing block {} on {}", blockHash, blockExplorerUri);
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.withAppendedPath(blockExplorerUri, "block/" + blockHash)));
return true;
}
return false;
}
});
popupMenu.show();
}
示例5: showMenu
import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showMenu(View v) {
PopupMenu popup = new PopupMenu(activity, v);
popup.setOnMenuItemClickListener(this);
popup.inflate(R.menu.song_list);
// Force icons to show
Object menuHelper;
Class[] argTypes;
try {
Field fMenuHelper = PopupMenu.class.getDeclaredField("mPopup");
fMenuHelper.setAccessible(true);
menuHelper = fMenuHelper.get(popup);
argTypes = new Class[]{boolean.class};
menuHelper.getClass().getDeclaredMethod("setForceShowIcon", argTypes).invoke(menuHelper, true);
} catch (Exception e) {
Log.w("TAG", "error forcing menu icons to show", e);
popup.show();
return;
}
popup.show();
}
示例6: showVerboseLogPopup
import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showVerboseLogPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal);
menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose);
menu.setGroupCheckable(Menu.NONE, true, true);
menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true);
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == 0) {
VerboseLogUtil.setEnableAllTags(false);
} else {
VerboseLogUtil.setEnableAllTags(true);
}
return true;
}
});
popup.show();
}
示例7: onLongClick
import android.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View buttonView) {
PopupMenu popup = new PopupMenu(ShowTopicActivity.this, buttonView);
MenuItem postAsModoItem;
popup.getMenuInflater().inflate(R.menu.menu_sendmessage_action, popup.getMenu());
popup.setOnMenuItemClickListener(onSendmessageActionClickedListener);
postAsModoItem = popup.getMenu().findItem(R.id.enable_postasmodo_sendmessage_action);
postAsModoItem.setChecked(PrefsManager.getBool(PrefsManager.BoolPref.Names.POST_AS_MODO_WHEN_POSSIBLE));
postAsModoItem.setEnabled(userCanPostAsModo);
popup.getMenu().findItem(R.id.action_past_last_message_sended_showtopic).setEnabled(!lastMessageSended.isEmpty());
popup.show();
return true;
}
示例8: onMenuClick
import android.widget.PopupMenu; //导入方法依赖的package包/类
private void onMenuClick(@NonNull final View btnView, final int position) {
final PopupMenu popup = new PopupMenu(btnView.getContext(), btnView);
final Menu popupMenu = popup.getMenu();
final MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.list_item_album, popupMenu);
final long id = getItemId(position);
final Cursor item = getCursor();
if (item.moveToPosition(position)) {
final String albumName = item.getString(AlbumsProvider.COLUMN_ALBUM);
popup.setOnMenuItemClickListener(menuItem -> onMenuItemClick(menuItem, id, albumName));
popup.show();
}
}
示例9: showHistory
import android.widget.PopupMenu; //导入方法依赖的package包/类
protected void showHistory() {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext);
List<String> items = getHistory(sharedPref);
PopupMenu popup = new PopupMenu(mContext, mEditor);
Menu root = popup.getMenu();
int len = items.size();
if (len > 10) len = 10;
for (int i = 0; i < len; i++) {
String text = items.get(i).trim();
if ((text != null) && (text.length() > 0)) {
root.add(text);
}
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
mEditor.setText(item.getTitle());
mEditor.setSelection(0, mEditor.length());
return true;
}
});
popup.show();
}
示例10: select
import android.widget.PopupMenu; //导入方法依赖的package包/类
public void select(View v) {
PopupMenu popup = new PopupMenu(this, v);
popup.getMenuInflater().inflate(R.menu.menu_select, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
PointerMode mode = new PointerMode();
switch (item.getItemId()) {
case R.id.rect_select_menu:
mode.setSelectionMode(new RectSelectionMode());
break;
case R.id.oval_select_menu:
mode.setSelectionMode(new OvalSelectionMode());
break;
case R.id.lasso_menu:
mode.setSelectionMode(new LassoSelectionMode());
break;
}
drawingBoard.getDrawingContext().setDrawingMode(mode);
return true;
}
});
popup.show();
}
示例11: onClick
import android.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
if (view == menu) {
PopupMenu popup = new PopupMenu(view.getContext(), view);
popup.inflate(R.menu.season_menu);
popup.setOnMenuItemClickListener(this);
popup.show();
}
}
示例12: RecycleViewBaseViewHolder
import android.widget.PopupMenu; //导入方法依赖的package包/类
protected RecycleViewBaseViewHolder(@Nonnull Context context, @Nonnull View itemView) {
super(itemView);
popupMenu = new PopupMenu(context, itemView);
popupMenu.setOnMenuItemClickListener(this);
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
}
示例13: onMenuOptionClick
import android.widget.PopupMenu; //导入方法依赖的package包/类
@OnClick(R.id.menu)
void onMenuOptionClick(View view) {
PopupMenu popupMenu = new PopupMenu(this, view);
MenuInflater menuInflater = popupMenu.getMenuInflater();
menuInflater.inflate(R.menu.options_main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(this);
popupMenu.show();
}
示例14: onClick
import android.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
PopupMenu popupMenu = new PopupMenu(activity, v);
popupMenu.inflate(getMenuRes());
popupMenu.setOnMenuItemClickListener(this);
popupMenu.show();
}
示例15: showPopupMenu
import android.widget.PopupMenu; //导入方法依赖的package包/类
private void showPopupMenu(View view, final int position) {
PopupMenu popup = new PopupMenu(getActivity(), view);
popup.getMenuInflater().inflate(R.menu.popup_connections, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onPopupMenuItemClick(menuItem, position);
}
});
popup.show();
}