List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { LibraryAdapter adapter = mCurrentAdapter; menu.findItem(MENU_SORT).setEnabled(adapter != null && adapter.getMediaType() != MediaUtils.TYPE_FILE); return super.onPrepareOptionsMenu(menu); }
From source file:de.elanev.studip.android.app.backend.net.oauth.SignInFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_sign_in, menu); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { MenuItem searchItem = menu.findItem(R.id.search_studip); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { @Override/*from w w w. ja va2s . c o m*/ public boolean onQueryTextSubmit(String s) { return false; } @Override public boolean onQueryTextChange(String s) { if (TextUtils.isEmpty(s)) { mListView.clearTextFilter(); } else { mListView.setFilterText(s); } return true; } }; searchView.setOnQueryTextListener(queryTextListener); } super.onCreateOptionsMenu(menu, inflater); }
From source file:com.ichi2.anki.Statistics.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // exit if mTaskHandler not initialized yet if (mTaskHandler == null) { return true; }/*from w ww. j a v a2 s .c om*/ switch (mTaskHandler.getStatType()) { case Stats.TYPE_MONTH: MenuItem monthItem = menu.findItem(R.id.item_time_month); monthItem.setChecked(true); break; case Stats.TYPE_YEAR: MenuItem yearItem = menu.findItem(R.id.item_time_year); yearItem.setChecked(true); break; case Stats.TYPE_LIFE: MenuItem lifeItem = menu.findItem(R.id.item_time_all); lifeItem.setChecked(true); break; } return super.onPrepareOptionsMenu(menu); }
From source file:com.adamas.client.android.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { _menuItemStartStop = menu.findItem(R.id.action_start_stop_vpn); MenuItem scan = menu.findItem(R.id.action_scan_qr_code); MenuItem delete = menu.findItem(R.id.action_delete_connector); MenuItem edit = menu.findItem(R.id.action_edit_connector); MenuItem importConnectorFile = menu.findItem(R.id.action_import_connector_from_image); MenuItem importConnectorText = menu.findItem(R.id.action_import_connector_from_text); MenuItem add = menu.findItem(R.id.action_add_connector_manually); MenuItem settings = menu.findItem(R.id.action_settings); if (_menuItemStartStop != null) { if (_currentActiveFragment == FRAGMENT_CONNECTORS) { _menuItemStartStop.setVisible(true); scan.setVisible(true);/*from w w w. j av a2s . com*/ importConnectorFile.setVisible(true); importConnectorText.setVisible(true); add.setVisible(true); settings.setVisible(true); if (_selectedAdamasConnector != null) { delete.setVisible(true); edit.setVisible(true); } else { delete.setVisible(false); edit.setVisible(false); } } else if (_currentActiveFragment == FRAGMENT_STATISTICS) { _menuItemStartStop.setVisible(false); scan.setVisible(false); importConnectorFile.setVisible(false); importConnectorText.setVisible(false); add.setVisible(false); settings.setVisible(true); delete.setVisible(false); edit.setVisible(false); } } return super.onPrepareOptionsMenu(menu); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.TaskDetailFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_tasks_detail, menu); // Locate MenuItem with ShareActionProvider MenuItem item = menu.findItem(R.id.menu_share); if (item != null) { // Fetch and store ShareActionProvider mShareActionProvider = MenuItemCompat.getActionProvider(item); setShareIntent(""); }/* w w w . j a v a2s . com*/ }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); menu.findItem(R.id.MENU_HOVER_TEXT).setVisible(comicDef.hasAltText()); menu.findItem(R.id.MENU_COMIC_LINK).setVisible(comicInfo.getLink() != null); menu.findItem(R.id.MENU_EXPLAIN).setVisible(provider.getExplainUrl(comicInfo) != null); return true;//from w ww.j a v a2 s. c o m }
From source file:fr.cph.chicago.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { this.mMenu = menu; getMenuInflater().inflate(R.menu.main, menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return super.onCreateOptionsMenu(menu); }
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 w w w . j a v a 2 s . 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.example.javier.MaterialDesignApp.PlayerActivity.java
public void showAudioPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio); final MenuItem backgroundAudioItem = menu.findItem(0); backgroundAudioItem.setCheckable(true); backgroundAudioItem.setChecked(enableBackgroundAudio); OnMenuItemClickListener clickListener = new OnMenuItemClickListener() { @Override/*from www . j av a2s .com*/ public boolean onMenuItemClick(MenuItem item) { if (item == backgroundAudioItem) { enableBackgroundAudio = !item.isChecked(); return true; } return false; } }; configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO); popup.show(); }
From source file:android_network.hetnet.vpn_service.ActivityLog.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // https://gist.github.com/granoeste/5574148 File pcap_file = new File(getDir("data", MODE_PRIVATE), "netguard.pcap"); boolean export = (getPackageManager().resolveActivity(getIntentPCAPDocument(), 0) != null); menu.findItem(R.id.menu_protocol_udp).setChecked(prefs.getBoolean("proto_udp", true)); menu.findItem(R.id.menu_protocol_tcp).setChecked(prefs.getBoolean("proto_tcp", true)); menu.findItem(R.id.menu_protocol_other).setChecked(prefs.getBoolean("proto_other", true)); menu.findItem(R.id.menu_traffic_allowed).setEnabled(prefs.getBoolean("filter", false)); menu.findItem(R.id.menu_traffic_allowed).setChecked(prefs.getBoolean("traffic_allowed", true)); menu.findItem(R.id.menu_traffic_blocked).setChecked(prefs.getBoolean("traffic_blocked", true)); menu.findItem(R.id.menu_refresh).setEnabled(!menu.findItem(R.id.menu_log_live).isChecked()); menu.findItem(R.id.menu_log_resolve).setChecked(prefs.getBoolean("resolve", false)); menu.findItem(R.id.menu_log_organization).setChecked(prefs.getBoolean("organization", false)); menu.findItem(R.id.menu_pcap_enabled).setChecked(prefs.getBoolean("pcap", false)); menu.findItem(R.id.menu_pcap_export).setEnabled(pcap_file.exists() && export); return super.onPrepareOptionsMenu(menu); }