Java Code Examples for android.app.Activity#getMenuInflater()
The following examples show how to use
android.app.Activity#getMenuInflater() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListFragmentTag.java From rss with GNU General Public License v3.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); boolean hasImage = ((ViewFeedItem) ((AdapterView.AdapterContextMenuInfo) menuInfo).targetView).m_hasImage; // Inflate the context menu from the xml file. Activity activity = getActivity(); MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.context_menu, menu); // Show the 'Save image' option only when the view has an image. menu.findItem(R.id.save_image).setVisible(hasImage); // Set the title of the context menu to the feed item's title. AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; FeedItem view = (FeedItem) ((AdapterView<ListAdapter>) v).getAdapter() .getItem(info.position); menu.setHeaderTitle(view.m_title); }
Example 2
Source File: FragmentTransactions.java From fingen with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); Activity activity = getActivity(); if (activity != null) { MenuInflater menuInflater = activity.getMenuInflater(); if (v.getId() == R.id.recycler_view) { contextMenuTarget = CONTEXT_MENU_TRANSACTIONS; menuInflater.inflate(R.menu.context_menu_transactions, menu); } } }