本文整理汇总了Java中android.widget.PopupMenu.OnMenuItemClickListener类的典型用法代码示例。如果您正苦于以下问题:Java OnMenuItemClickListener类的具体用法?Java OnMenuItemClickListener怎么用?Java OnMenuItemClickListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnMenuItemClickListener类属于android.widget.PopupMenu包,在下文中一共展示了OnMenuItemClickListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showPopupMenu
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
protected void showPopupMenu(View view, final int position) {
final FavoriteArticle article = (FavoriteArticle) getItem(position);
PopupMenu popup = new PopupMenu(this.context, view);
popup.getMenu().add(0, 0, 0, "取消收藏");
popup.show();
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case 0:
WebFavoriteFragment.this.deleteFavoriteArticle(article, position);
break;
}
return false;
}
});
}
示例2: onBlockMenuClick
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的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();
}
示例3: showAudioPopup
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
public void showAudioPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
final MenuItem backgroundAudioItem = menu.findItem(0);
backgroundAudioItem.setCheckable(true);
backgroundAudioItem.setChecked(enableBackgroundAudio);
OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item == backgroundAudioItem) {
enableBackgroundAudio = !item.isChecked();
return true;
}
return false;
}
};
configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
popup.show();
}
示例4: showVerboseLogPopup
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的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();
}
示例5: configurePopupWithTracks
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener,
final int trackType) {
if (player == null) {
return;
}
int trackCount = player.getTrackCount(trackType);
if (trackCount == 0) {
return;
}
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item))
|| onTrackItemClick(item, trackType);
}
});
Menu menu = popup.getMenu();
// ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0)
menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off);
for (int i = 0; i < trackCount; i++) {
menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, buildTrackName(player.getTrackFormat(trackType, i)));
}
menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true);
}
示例6: showAudioPopup
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
public void showAudioPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
final MenuItem backgroundAudioItem = menu.findItem(0);
backgroundAudioItem.setCheckable(true);
backgroundAudioItem.setChecked(enableBackgroundAudio);
OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item == backgroundAudioItem) {
enableBackgroundAudio = !item.isChecked();
return true;
}
return false;
}
};
configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
popup.show();
}
示例7: showVerboseLogPopup
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的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();
}
示例8: onBlockMenuClick
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的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.setOnMenuItemClickListener(new OnMenuItemClickListener()
{
@Override
public boolean onMenuItemClick(final MenuItem item)
{
switch (item.getItemId())
{
case R.id.blocks_context_browse:
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.withAppendedPath(config.getBlockExplorer(), "block/" + block.getHeader().getHashAsString())));
return true;
}
return false;
}
});
popupMenu.show();
}
示例9: onPopupMenu
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
if (!AndroidUtil.isHoneycombOrLater()) {
// Call the "classic" context menu
anchor.performLongClick();
return;
}
PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
setContextMenuItems(popupMenu.getMenu(), anchor, position);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return handleContextItemSelected(item, position);
}
});
popupMenu.show();
}
示例10: onPopupMenu
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
if (!AndroidUtil.isHoneycombOrLater()) {
// Call the "classic" context menu
anchor.performLongClick();
return;
}
PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
setContextMenuItems(popupMenu.getMenu(), anchor);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return handleContextItemSelected(item, position);
}
});
popupMenu.show();
}
示例11: onContextPopupMenu
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onContextPopupMenu(View anchor, final int position) {
if (!AndroidUtil.isHoneycombOrLater()) {
// Call the "classic" context menu
anchor.performLongClick();
return;
}
PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu());
MediaWrapper media = mVideoAdapter.getItem(position);
if (media == null)
return;
setContextMenuItems(popupMenu.getMenu(), media);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return handleContextItemSelected(item, position);
}
});
popupMenu.show();
}
示例12: ServerViewHolder
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
public ServerViewHolder(View view) {
super(view);
view.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(final View v) {
PopupMenu menu = ServerInfoUtil.createContextMenu(context, v, new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return ServerInfoUtil.onMenuItemClick(context, item, serverInfo, after);
}
});
menu.show();
return true;
}
});
icon = (ImageView) view.findViewById(R.id.icon);
serverName = (TextView) view.findViewById(R.id.server_name);
serverAddress = (TextView) view.findViewById(R.id.server_address);
serverLocator = (TextView) view.findViewById(R.id.server_locator_id);
serverLastConnected = (TextView) view.findViewById(R.id.server_last_connect);
}
示例13: showAudioPopup
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
public void showAudioPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
final MenuItem backgroundAudioItem = menu.findItem(0);
backgroundAudioItem.setCheckable(true);
backgroundAudioItem.setChecked(enableBackgroundAudio);
OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item == backgroundAudioItem) {
enableBackgroundAudio = !item.isChecked();
return true;
}
return false;
}
};
configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
popup.show();
}
示例14: showVerboseLogPopup
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的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();
}
示例15: onLongPress
import android.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
@Override
public void onLongPress(MotionEvent e) {
mView.setPressed(false);
PopupMenu menu = new PopupMenu(mContext, mView);
menu.inflate(R.menu.notification_menu);
menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if(item.getItemId() == R.id.action_info) {
ControlService service = (ControlService) ControlService.getInstance();
if(service != null && service.isAttachedToWindow() && ControlService.isRunning()) {
service.close();
}
startApplicationDetailsActivity(mPkg);
return true;
}
return false;
}
});
menu.show();
}