本文整理了Java中android.view.ContextMenu.findItem()
方法的一些代码示例,展示了ContextMenu.findItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ContextMenu.findItem()
方法的具体详情如下:
包路径:android.view.ContextMenu
类名称:ContextMenu
方法名:findItem
暂无
代码示例来源:origin: k9mail/k-9
menu.findItem(R.id.debug_delete_locally).setVisible(BuildConfig.DEBUG);
menu.findItem(R.id.select).setVisible(false);
} else {
menu.findItem(R.id.deselect).setVisible(false);
menu.findItem(R.id.mark_as_read).setVisible(false);
} else {
menu.findItem(R.id.mark_as_unread).setVisible(false);
menu.findItem(R.id.flag).setVisible(false);
} else {
menu.findItem(R.id.unflag).setVisible(false);
menu.findItem(R.id.copy).setVisible(false);
menu.findItem(R.id.move).setVisible(false);
menu.findItem(R.id.archive).setVisible(false);
menu.findItem(R.id.spam).setVisible(false);
menu.findItem(R.id.archive).setVisible(false);
menu.findItem(R.id.spam).setVisible(false);
代码示例来源:origin: k9mail/k-9
EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account);
if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
menu.findItem(R.id.move_up).setEnabled(false);
menu.findItem(R.id.move_up).setEnabled(true);
menu.findItem(R.id.move_down).setEnabled(false);
menu.findItem(R.id.move_down).setEnabled(true);
代码示例来源:origin: Neamar/KISS
void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (prefs.getBoolean("history-hide", true)) {
if (widgetUsed) {
menu.findItem(R.id.widget).setTitle(R.string.menu_widget_remove);
} else {
menu.findItem(R.id.widget).setTitle(R.string.menu_widget_add);
}
} else {
menu.findItem(R.id.widget).setVisible(false);
}
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
//Set a title for the context menu
menu.setHeaderTitle("Title of menu");
// Select a menu item then change it's title (text)
MenuItem mi = (MenuItem) menu.findItem(R.id.new_game);
mi.setTitle("Text of item");
}
代码示例来源:origin: calvinaquino/LNReader-Android
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.context_menu_update_history, menu);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
UpdateInfoModel chapter = updateList.get(info.position);
if (chapter.getUpdateType() == UpdateTypeEnum.NewNovel) {
menu.findItem(R.id.menu_open_chapter).setVisible(false);
} else {
menu.findItem(R.id.menu_open_chapter).setVisible(true);
}
}
代码示例来源:origin: lordi/tickmate
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo)menuInfo;
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
Track t = (Track)tracksAdapter.getItem((int)info.id);
inflater.inflate(R.menu.edit_tracks_context_menu, menu);
menu.findItem(R.id.edit_tracks_deactivate).setVisible(t.isEnabled());
menu.findItem(R.id.edit_tracks_activate).setVisible(!t.isEnabled());
}
代码示例来源:origin: gateship-one/odyssey
/**
* Create the context menu.
*/
@Override
public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.context_menu_playlist_tracks_fragment, menu);
if (mPlaylistPath != null) {
// Hide remove track for playlist files as it is unsupported
menu.findItem(R.id.fragment_playlist_tracks_action_remove).setVisible(false);
}
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.comments_context, menu);
menu.setHeaderTitle("Available Actions");
MenuItem Edit = menu.findItem(R.id.editComment);
MenuItem Delete = menu.findItem(R.id.deleteComment);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
int position = info.position;
ListView lv = (ListView) v;
int firstVisible = lv.getFirstVisiblePosition();
View rowView = lv.getChildAt(position - firstVisible);
ReviewUser = ((TextView) rowView.findViewById(R.id.labelReviewCommentUser))
.getText().toString();
ReviewComment = ((TextView) rowView.findViewById(R.id.labelReviewComment))
.getText().toString();
}
代码示例来源:origin: vbier/habpanelviewer
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.webview_context_menu, menu);
menu.findItem(R.id.menu_toggle_kiosk).setVisible(mWebView.isShowingHabPanel());
}
代码示例来源:origin: Chengel-HaltuD/WeChatForward
protected void d(XC_MethodHook.MethodHookParam paramMethodHookParam) {
ContextMenu localContextMenu = (ContextMenu) paramMethodHookParam.args[0];
View view = (View) paramMethodHookParam.args[1];
if (view.getTag() != null) {
Log.i("Chengel_HaltuD", "11111111111111122222222222");
if (localContextMenu.findItem(1000) == null) {
Log.i("Chengel_HaltuD", "33333333333333333333333");
// Object localObject2 = (ListView)XposedHelpers.getObjectField(paramMethodHookParam.thisObject, "dPX");
Object tag = view.getTag();
localContextMenu.add(0, 1000, 0, "转发到朋友圈").setOnMenuItemClickListener(new ae(this, tag));
Log.i("Chengel_HaltuD", "444444444444444444444444");
} else {
}
} else {
}
}
代码示例来源:origin: labexp/osmtracker-android
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
getMenuInflater().inflate(R.menu.trackmgr_contextmenu, menu);
long selectedId = ((AdapterContextMenuInfo) menuInfo).id;
menu.setHeaderTitle(getResources().getString(R.string.trackmgr_contextmenu_title).replace("{0}", Long.toString(selectedId)));
if(currentTrackId == selectedId){
// the selected one is the active track, so we will show the stop item
menu.findItem(R.id.trackmgr_contextmenu_stop).setVisible(true);
}else{
// the selected item is not active, so we need to hide the stop item
menu.findItem(R.id.trackmgr_contextmenu_stop).setVisible(false);
}
menu.setHeaderTitle(getResources().getString(R.string.trackmgr_contextmenu_title).replace("{0}", Long.toString(selectedId)));
if ( currentTrackId == selectedId) {
// User has pressed the active track, hide the delete option
menu.removeItem(R.id.trackmgr_contextmenu_delete);
}
}
代码示例来源:origin: bparmentier/WiFiKeyShare
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
int itemPosition = ((ContextMenuRecyclerView.RecyclerContextMenuInfo) menuInfo).position;
menu.setHeaderTitle(wifiNetworks.get(itemPosition).getSsid());
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.context_menu, menu);
boolean canViewPasword = wifiNetworks.get(itemPosition).isPasswordProtected()
&& !wifiNetworks.get(itemPosition).getKey().isEmpty();
boolean canClearPassword = canViewPasword;
MenuItem viewPasswordMenuItem = menu.findItem(R.id.context_menu_wifi_list_view_password);
viewPasswordMenuItem.setEnabled(canViewPasword);
MenuItem clearPasswordMenuItem = menu.findItem(R.id.context_menu_wifi_list_clear_password);
clearPasswordMenuItem.setEnabled(canClearPassword);
clearPasswordMenuItem.setVisible(!isDeviceRooted);
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle(R.string.menu_title);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
// loop for menu items
for (int i = 0; i < menu.size(); ++i) {
MenuItem mi = menu.getItem(i);
// check the Id as you wish
if (mi.getItemId() == R.id.item2) {
mi.setChecked(true);
}
}
}
MenuItem mi = menu.findItem(R.id.item2)
代码示例来源:origin: PrivacyApps/document-viewer
protected void createFileMenu(final ContextMenu menu, final String path) {
final BookSettings bs = SettingsManager.getBookSettings(path);
final MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.book_menu, menu);
menu.setHeaderTitle(path);
menu.findItem(R.id.bookmenu_recentgroup).setVisible(bs != null);
menu.findItem(R.id.bookmenu_openbookshelf).setVisible(false);
menu.findItem(R.id.bookmenu_openbookfolder).setVisible(false);
final MenuItem om = menu.findItem(R.id.bookmenu_open);
final SubMenu osm = om != null ? om.getSubMenu() : null;
if (osm == null) {
return;
}
osm.clear();
final List<Bookmark> list = new ArrayList<Bookmark>();
list.add(new Bookmark(true, getString(R.string.bookmark_start), PageIndex.FIRST, 0, 0));
list.add(new Bookmark(true, getString(R.string.bookmark_end), PageIndex.LAST, 0, 1));
if (bs != null) {
if (LengthUtils.isNotEmpty(bs.bookmarks)) {
list.addAll(bs.bookmarks);
}
list.add(new Bookmark(true, getString(R.string.bookmark_current), bs.currentPage, bs.offsetX, bs.offsetY));
}
Collections.sort(list);
for (final Bookmark b : list) {
addBookmarkMenuItem(osm, b);
}
}
代码示例来源:origin: stackoverflow.com
MenuInflater inflater = this.getActivity().getMenuInflater();
inflater.inflate(R.menu.menulistitem, menu);
MenuItem mi = menu.findItem(R.id.action_context_delete);
Intent i = new Intent();
代码示例来源:origin: gateship-one/odyssey
/**
* Create the context menu.
*/
@Override
public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getActivity().getMenuInflater();
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
FileModel currentFile = mAdapter.getItem(info.position);
if (currentFile.isFile()) {
// show context menu for files
inflater.inflate(R.menu.context_menu_files_files_fragment, menu);
// hide enqueue as next for playlist files
menu.findItem(R.id.fragment_files_action_enqueueasnext).setVisible(!currentFile.isPlaylist());
} else {
// show context menu for directories
inflater.inflate(R.menu.context_menu_directories_files_fragment, menu);
}
}
代码示例来源:origin: gateship-one/odyssey
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if (v.getId() == R.id.list_linear_listview && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu_current_playlist, menu);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
try {
if (getPlaybackService().getCurrentIndex() == info.position) {
menu.findItem(R.id.view_current_playlist_action_playnext).setVisible(false);
}
} catch (RemoteException e) {
e.printStackTrace();
}
CurrentPlaylistView currentPlaylistView = findViewById(R.id.now_playing_playlist);
// check if track has a valid album key
String albumKey = currentPlaylistView.getAlbumKey(info.position);
AlbumModel tmpAlbum = MusicLibraryHelper.createAlbumModelFromKey(albumKey, getApplicationContext());
menu.findItem(R.id.view_current_playlist_action_showalbum).setVisible(tmpAlbum != null);
// check if track has a valid artist id
String artistTitle = currentPlaylistView.getArtistTitle(info.position);
long artistID = MusicLibraryHelper.getArtistIDFromName(artistTitle, this);
menu.findItem(R.id.view_current_playlist_action_showartist).setVisible(artistID != -1);
// check the view type
if (currentPlaylistView.getItemViewType(info.position) == CurrentPlaylistAdapter.VIEW_TYPES.TYPE_SECTION_TRACK_ITEM) {
menu.findItem(R.id.view_current_playlist_action_remove_section).setVisible(true);
}
}
}
代码示例来源:origin: mkulesh/microMathematics
if ((mode & MODE_SORTING) == SORT_NAME)
activeSort = menu.findItem(R.id.fman_action_sort_by_name);
activeSort = menu.findItem(R.id.fman_action_sort_by_ext);
activeSort = menu.findItem(R.id.fman_action_sort_by_size);
activeSort = menu.findItem(R.id.fman_action_sort_by_date);
代码示例来源:origin: zulip/zulip-android
inflater.inflate(R.menu.context_stream, menu);
if (msg.getSender().getId() != ZulipApp.get().getYou().getId()) {
menu.findItem(R.id.edit_message).setVisible(false);
menu.findItem(R.id.star_message).setVisible(false);
} else {
menu.findItem(R.id.un_star_message).setVisible(false);
inflater.inflate(R.menu.context_private, menu);
if (msg.getSender().getId() != ZulipApp.get().getYou().getId()) {
menu.findItem(R.id.edit_message).setVisible(false);
menu.findItem(R.id.star_message).setVisible(false);
} else {
menu.findItem(R.id.un_star_message).setVisible(false);
inflater.inflate(R.menu.context_single_private, menu);
if (msg.getSender().getId() != ZulipApp.get().getYou().getId()) {
menu.findItem(R.id.edit_message).setVisible(false);
menu.findItem(R.id.star_message).setVisible(false);
} else {
menu.findItem(R.id.un_star_message).setVisible(false);
代码示例来源:origin: PrivacyApps/document-viewer
menu.findItem(R.id.bookmenu_recentgroup).setVisible(bs != null);
menu.findItem(R.id.bookmenu_openbookshelf).setVisible(
bookShelf != null && current != null && bookShelf != current);
final MenuItem om = menu.findItem(R.id.bookmenu_open);
final SubMenu osm = om != null ? om.getSubMenu() : null;
if (osm == null) {
内容来源于网络,如有侵权,请联系作者删除!