List of usage examples for android.view MenuInflater inflate
public void inflate(@MenuRes int menuRes, Menu menu)
From source file:net.reichholf.dreamdroid.fragment.MediaPlayerFragment.java
@Override public void createOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.mediaplayer, menu); }
From source file:org.artoolkit.ar.samples.ARMovie.ARMovieActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options, menu); return true;//from w w w .ja va 2s .c om }
From source file:com.wikitude.virtualhome.AugmentedActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Maintain different menu items based on marker/markerless if (markerPresent.equals("YES")) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_augmented, menu); } else if (markerPresent.equals("NO")) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.augmented_actions, menu); }/*from w w w.java 2 s . c o m*/ return super.onCreateOptionsMenu(menu); }
From source file:at.software2014.trackme.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.start, menu); return super.onCreateOptionsMenu(menu); }
From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java
@Override public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { MenuInflater inflater = actionMode.getMenuInflater(); inflater.inflate(R.menu.conversation_secondary, menu); return true;/* w w w. j a va 2s .c o m*/ }
From source file:pl.bcichecki.rms.client.android.fragments.EventsListFragment.java
private void setUpActionModeOnListItems() { getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override/* w ww . j a va 2 s . c om*/ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return performAction(mode, item); } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.fragment_events_list_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { if (checked) { verifyMenuItems(mode.getMenu()); for (int i = 0; i < getListView().getCheckedItemPositions().size(); i++) { if (i != position) { getListView().setItemChecked(i, false); } } } } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } private void verifyMenuItems(Menu menu) { Event checkedEvent = getFirstCheckedItem(); menu.findItem(R.id.fragment_events_list_context_menu_archive) .setVisible(!checkedEvent.isArchived()); menu.findItem(R.id.fragment_events_list_context_menu_edit) .setVisible(!checkedEvent.isArchived() || !checkedEvent.isLocked()); menu.findItem(R.id.fragment_events_list_context_menu_lock).setVisible(!checkedEvent.isLocked()); menu.findItem(R.id.fragment_events_list_context_menu_share).setVisible(!checkedEvent.isArchived()); menu.findItem(R.id.fragment_events_list_context_menu_unlock).setVisible(checkedEvent.isLocked()); } }); }
From source file:com.ichi2.anki.Statistics.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); mMenu = menu;/*ww w . jav a 2s. co m*/ //System.err.println("in onCreateOptionsMenu"); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.anki_stats, mMenu); return true; }
From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.conversation, menu); this.menu = menu; if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { MenuItem phoneMenuItem = menu.findItem(R.id.call_button); phoneMenuItem.setVisible(false); }/*from www . j a v a2s . c om*/ SearchView searchView = (SearchView) menu.findItem(R.id.search_button).getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { adapter.refresh(newText); return true; } }); return super.onCreateOptionsMenu(menu); }
From source file:com.notepadlite.NoteListFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void listNotes() { // Get number of files int numOfFiles = getNumOfNotes(getActivity().getFilesDir()); int numOfNotes = numOfFiles; // Get array of file names String[] listOfFiles = getListOfNotes(getActivity().getFilesDir()); ArrayList<String> listOfNotes = new ArrayList<>(); // Remove any files from the list that aren't notes for (int i = 0; i < numOfFiles; i++) { if (NumberUtils.isNumber(listOfFiles[i])) listOfNotes.add(listOfFiles[i]); else// w w w . j av a 2 s . c om numOfNotes--; } // Declare ListView final ListView listView = (ListView) getActivity().findViewById(R.id.listView1); // Create arrays of note lists String[] listOfNotesByDate = new String[numOfNotes]; String[] listOfNotesByName = new String[numOfNotes]; NoteListItem[] listOfTitlesByDate = new NoteListItem[numOfNotes]; NoteListItem[] listOfTitlesByName = new NoteListItem[numOfNotes]; ArrayList<NoteListItem> list = new ArrayList<>(numOfNotes); for (int i = 0; i < numOfNotes; i++) { listOfNotesByDate[i] = listOfNotes.get(i); } // If sort-by is "by date", sort in reverse order if (sortBy.equals("date")) Arrays.sort(listOfNotesByDate, Collections.reverseOrder()); // Get array of first lines of each note for (int i = 0; i < numOfNotes; i++) { try { String title = listener.loadNoteTitle(listOfNotesByDate[i]); String date = listener.loadNoteDate(listOfNotesByDate[i]); listOfTitlesByDate[i] = new NoteListItem(title, date); } catch (IOException e) { showToast(R.string.error_loading_list); } } // If sort-by is "by name", sort alphabetically if (sortBy.equals("name")) { // Copy titles array System.arraycopy(listOfTitlesByDate, 0, listOfTitlesByName, 0, numOfNotes); // Sort titles Arrays.sort(listOfTitlesByName, NoteListItem.NoteComparatorTitle); // Initialize notes array for (int i = 0; i < numOfNotes; i++) listOfNotesByName[i] = "new"; // Copy filenames array with new sort order of titles and nullify date arrays for (int i = 0; i < numOfNotes; i++) { for (int j = 0; j < numOfNotes; j++) { if (listOfTitlesByName[i].getNote().equals(listOfTitlesByDate[j].getNote()) && listOfNotesByName[i].equals("new")) { listOfNotesByName[i] = listOfNotesByDate[j]; listOfNotesByDate[j] = ""; listOfTitlesByDate[j] = new NoteListItem("", ""); } } } // Populate ArrayList with notes, showing name as first line of the notes list.addAll(Arrays.asList(listOfTitlesByName)); } else if (sortBy.equals("date")) list.addAll(Arrays.asList(listOfTitlesByDate)); // Create the custom adapters to bind the array to the ListView final NoteListDateAdapter dateAdapter = new NoteListDateAdapter(getActivity(), list); final NoteListAdapter adapter = new NoteListAdapter(getActivity(), list); // Display the ListView if (showDate) listView.setAdapter(dateAdapter); else listView.setAdapter(adapter); // Finalize arrays to prepare for handling clicked items final String[] finalListByDate = listOfNotesByDate; final String[] finalListByName = listOfNotesByName; // Make ListView handle clicked items listView.setClickable(true); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { if (sortBy.equals("date")) { if (directEdit) listener.editNote(finalListByDate[position]); else listener.viewNote(finalListByDate[position]); } else if (sortBy.equals("name")) { if (directEdit) listener.editNote(finalListByName[position]); else listener.viewNote(finalListByName[position]); } } }); // Make ListView handle contextual action bar final ArrayList<String> cab = new ArrayList<>(numOfNotes); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB switch (item.getItemId()) { case R.id.action_export: mode.finish(); // Action picked, so close the CAB listener.exportNote(cab.toArray()); return true; case R.id.action_delete: mode.finish(); // Action picked, so close the CAB listener.deleteNote(cab.toArray()); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { listener.hideFab(); // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.context_menu, menu); // Clear any old values from cab array cab.clear(); return true; } @Override public void onDestroyActionMode(ActionMode mode) { listener.showFab(); } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Add/remove filenames to cab array as they are checked/unchecked if (checked) { if (sortBy.equals("date")) cab.add(finalListByDate[position]); if (sortBy.equals("name")) cab.add(finalListByName[position]); } else { if (sortBy.equals("date")) cab.remove(finalListByDate[position]); if (sortBy.equals("name")) cab.remove(finalListByName[position]); } // Update the title in CAB if (cab.size() == 0) mode.setTitle(""); else mode.setTitle(cab.size() + " " + listener.getCabString(cab.size())); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }); // If there are no saved notes, then display the empty view if (numOfNotes == 0) { TextView empty = (TextView) getActivity().findViewById(R.id.empty); listView.setEmptyView(empty); } }
From source file:com.openerp.addons.messages.MessageDetail.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // TODO Auto-generated method stub inflater.inflate(R.menu.menu_fragment_message_detail, menu); }