List of usage examples for android.app Activity getMenuInflater
@NonNull
public MenuInflater getMenuInflater()
From source file:com.example.ray.firstapp.bottombar.MiscUtils.java
/** * A hacky method for inflating menus from xml resources to an array * of BottomBarTabs./*from www .jav a 2 s .co m*/ * * @param activity the activity context for retrieving the MenuInflater. * @param menuRes the xml menu resource to inflate * @return an Array of BottomBarTabs. */ protected static BottomBarTab[] inflateMenuFromResource(Activity activity, @MenuRes int menuRes) { // A bit hacky, but hey hey what can I do PopupMenu popupMenu = new PopupMenu(activity, null); Menu menu = popupMenu.getMenu(); activity.getMenuInflater().inflate(menuRes, menu); int menuSize = menu.size(); BottomBarTab[] tabs = new BottomBarTab[menuSize]; for (int i = 0; i < menuSize; i++) { MenuItem item = menu.getItem(i); BottomBarTab tab = new BottomBarTab(item.getIcon(), String.valueOf(item.getTitle())); tab.id = item.getItemId(); tabs[i] = tab; } return tabs; }
From source file:com.ultramegasoft.flavordex2.fragment.CatListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final Activity activity = getActivity(); if (activity == null) { return;/*from w w w .j a v a 2 s .co m*/ } final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; if (mAdapter.getShowAllCats() && info.position == 0) { return; } activity.getMenuInflater().inflate(R.menu.cat_context_menu, menu); if (mAdapter.getItem(info.position).preset) { menu.findItem(R.id.menu_delete).setEnabled(false).setVisible(false); } }
From source file:org.openpilot_nonag.androidgcs.fragments.Map.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); Activity mapAct = this.getActivity(); MenuInflater inflater = mapAct.getMenuInflater(); inflater.inflate(R.menu.map_click_actions, menu); }
From source file:com.android.browser.BookmarksPageCallbacks.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { BookmarkContextMenuInfo info = (BookmarkContextMenuInfo) menuInfo; BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition); Cursor cursor = adapter.getItem(info.childPosition); if (!canEdit(cursor)) { return;//from w ww . j av a 2 s . c om } boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; final Activity activity = getActivity(); MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.bookmarkscontext, menu); if (isFolder) { menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true); } else { menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true); if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } } BookmarkItem header = new BookmarkItem(activity); header.setEnableScrolling(true); populateBookmarkItem(cursor, header, isFolder); menu.setHeaderView(header); int count = menu.size(); for (int i = 0; i < count; i++) { menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener); } }
From source file:com.baohume.browser.BookmarksPageCallbacks.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { BookmarkExpandableView.BookmarkContextMenuInfo info = (BookmarkExpandableView.BookmarkContextMenuInfo) menuInfo; BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition); Cursor cursor = adapter.getItem(info.childPosition); if (!canEdit(cursor)) { return;/*from w w w.java 2s . co m*/ } boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; final Activity activity = getActivity(); MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.bookmarkscontext, menu); if (isFolder) { menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true); } else { menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true); if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } } BookmarkItem header = new BookmarkItem(activity); header.setEnableScrolling(true); populateBookmarkItem(cursor, header, isFolder); menu.setHeaderView(header); int count = menu.size(); for (int i = 0; i < count; i++) { menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener); } }
From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { BookmarkContextMenuInfo info = (BookmarkContextMenuInfo) menuInfo; BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition); Cursor cursor = adapter.getItem(info.childPosition); if (!canEdit(cursor)) { return;/* w ww. jav a 2 s. c om*/ } boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; final Activity activity = this; MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.bookmarkscontext, menu); if (isFolder) { menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true); } else { menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true); if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } } BookmarkItem header = new BookmarkItem(activity); header.setEnableScrolling(true); populateBookmarkItem(cursor, header, isFolder); menu.setHeaderView(header); int count = menu.size(); for (int i = 0; i < count; i++) { menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener); } }
From source file:com.ultramegasoft.flavordex2.fragment.EntryListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final Activity activity = getActivity(); if (activity != null) { activity.getMenuInflater().inflate(R.menu.entry_context_menu, menu); }//from w w w. j av a 2 s. c o m }