List of usage examples for android.view MenuInflater inflate
public void inflate(@MenuRes int menuRes, Menu menu)
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { if (licenseValid == null) { menuInflater.inflate(R.menu.empty, menu); } else if (albumListType != null && !"starred".equals(albumListType)) { menuInflater.inflate(R.menu.select_album_list, menu); } else if (artist && !showAll) { menuInflater.inflate(R.menu.select_album, menu); if (!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); }//from w w w . j av a2 s . c o m if (!ServerInfo.checkServerVersion(context, "1.11")) { menu.removeItem(R.id.menu_radio); menu.removeItem(R.id.menu_similar_artists); } else if (!ServerInfo.hasSimilarArtists(context)) { menu.removeItem(R.id.menu_similar_artists); } } else { if (podcastId == null) { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_offline, menu); } else { menuInflater.inflate(R.menu.select_song, menu); if (playlistId == null || !playlistOwner) { menu.removeItem(R.id.menu_remove_playlist); } } SharedPreferences prefs = Util.getPreferences(context); if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_NEXT, true)) { menu.setGroupVisible(R.id.hide_play_next, false); } if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_LAST, true)) { menu.setGroupVisible(R.id.hide_play_last, false); } } else { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_podcast_episode_offline, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode, menu); if (!UserUtil.canPodcast()) { menu.removeItem(R.id.menu_download_all); } } } } if ("starred".equals(albumListType)) { menuInflater.inflate(R.menu.unstar, menu); } }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.option_menu, menu); return true;/*from www.j a v a 2 s.co m*/ }
From source file:gc.david.dfm.ui.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Mint.leaveBreadcrumb("MainActivity::onCreateOptionsMenu"); // Inflate the options menu from XML final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); // Expandir el EditText de la bsqueda a lo largo del ActionBar searchMenuItem = menu.findItem(R.id.action_search); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); // Configure the search info and add any event listeners final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); // Indicamos que la activity actual sea la buscadora searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(false); searchView.setQueryRefinementEnabled(true); searchView.setIconifiedByDefault(true); // Muestra el item de men de cargar si hay elementos en la BD final MenuItem loadItem = menu.findItem(R.id.action_load); // TODO hacerlo en segundo plano final List<Distance> allDistances = getApplicationDaoSession().loadAll(Distance.class); if (allDistances.size() == 0) { loadItem.setVisible(false);//from w ww . j a va 2 s . c o m } return super.onCreateOptionsMenu(menu); }
From source file:com.ichi2.anki.NoteEditor.java
private void setMMButtonListener(ImageButton mediaButton, final int index) { mediaButton.setOnClickListener(new View.OnClickListener() { @Override//from w w w . j av a 2s . c o m public void onClick(View v) { Timber.i("NoteEditor:: Multimedia button pressed for field %d", index); final Collection col = CollectionHelper.getInstance().getCol(NoteEditor.this); if (mEditorNote.items()[index][1].length() > 0) { // If the field already exists then we start the field editor, which figures out the type // automatically IMultimediaEditableNote mNote = NoteService.createEmptyNote(mEditorNote.model()); NoteService.updateMultimediaNoteFromJsonNote(col, mEditorNote, mNote); IField field = mNote.getField(index); startMultimediaFieldEditor(index, mNote, field); } else { // Otherwise we make a popup menu allowing the user to choose between audio/image/text field // TODO: Update the icons for dark material theme, then can set 3rd argument to true PopupMenuWithIcons popup = new PopupMenuWithIcons(NoteEditor.this, v, false); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.popupmenu_multimedia_options, popup.getMenu()); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { IMultimediaEditableNote mNote = NoteService.createEmptyNote(mEditorNote.model()); NoteService.updateMultimediaNoteFromJsonNote(col, mEditorNote, mNote); IField field; switch (item.getItemId()) { case R.id.menu_multimedia_audio: Timber.i("NoteEditor:: Record audio button pressed"); field = new AudioField(); mNote.setField(index, field); startMultimediaFieldEditor(index, mNote, field); return true; case R.id.menu_multimedia_photo: Timber.i("NoteEditor:: Add image button pressed"); field = new ImageField(); mNote.setField(index, field); startMultimediaFieldEditor(index, mNote, field); return true; case R.id.menu_multimedia_text: Timber.i("NoteEditor:: Advanced editor button pressed"); field = new TextField(); field.setText(mEditFields.get(index).getText().toString()); mNote.setField(index, field); startMultimediaFieldEditor(index, mNote, field); return true; default: return false; } } }); popup.show(); } } }); }
From source file:net.phase.wallet.Currency.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.mainmenu, menu); return true;/* w w w.j a va 2 s . c o m*/ }
From source file:net.phase.wallet.Currency.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.walletmenu, menu); }
From source file:de.geeksfactory.opacclient.frontend.AccountFragment.java
@SuppressLint("NewApi") @Override/* ww w. j a v a2s.c o m*/ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.activity_account, menu); if (app.getAccount() != null && (app.getApi().getSupportFlags() & OpacApi.SUPPORT_FLAG_ACCOUNT_PROLONG_ALL) != 0) { menu.findItem(R.id.action_prolong_all).setVisible(true); } else { menu.findItem(R.id.action_prolong_all).setVisible(false); } menu.findItem(R.id.action_refresh).setVisible(supported); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.dycody.android.idealnote.ListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_list, menu); super.onCreateOptionsMenu(menu, inflater); this.menu = menu; initSearchView(menu);/*from www . j a v a2s. c om*/ }
From source file:com.gelakinetic.mtgfam.fragments.CardViewFragment.java
/** * Inflate the ActionBar items/*from www.java 2s. c om*/ * * @param menu The options menu in which you place your items. * @param inflater The inflater to use to inflate the menu */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.card_menu, menu); }