List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT) .equals(MainActivity.HOLO_LIGHT)) inflater.inflate(R.menu.main, menu); else/*from w ww . j a v a 2 s.co m*/ inflater.inflate(R.menu.main_dark, menu); menu.findItem(R.id.action_search).setVisible(true); menu.findItem(R.id.action_refresh).setVisible(true); MenuItem searchItem = menu.findItem(R.id.action_search); mSearchView = (SearchView) searchItem.getActionView(); mSearchView.setQueryHint("Lookup Users"); SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { // Do nothing return true; } @Override public boolean onQueryTextSubmit(String query) { Log.d("searching", mSearchView.getQuery() + ""); Intent intent = new Intent(); intent.putExtra("username", mSearchView.getQuery().toString()); intent.setAction(ImgurHoloActivity.ACCOUNT_INTENT); intent.addCategory(Intent.CATEGORY_DEFAULT); startActivity(intent); return true; } }; mSearchView.setOnQueryTextListener(queryTextListener); }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.activities.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflates default menu, adds search icon (no drawable found, using IconDrawable library.) getMenuInflater().inflate(R.menu.menu_main, menu); menu.findItem(R.id.action_search).setIcon(new IconDrawable(this, Iconify.IconValue.fa_search) .colorRes(R.color.accentNoTransparency).actionBarSize()); return true;//from www . j av a 2 s . co m }
From source file:com.lairdtech.lairdtoolkit.serialdevice.SerialActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.serial, menu); getActionBar().setIcon(R.drawable.icon_serial); getActionBar().setDisplayHomeAsUpEnabled(true); if (mBluetoothAdapterWrapper.isBleScanning() == true) { menu.findItem(R.id.action_scanning_indicator).setActionView(R.layout.progress_indicator); } else {/*from w ww. j a va2s .com*/ menu.findItem(R.id.action_scanning_indicator).setActionView(null); } return true; }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu_report_income_vs_expenses, menu); // fix menu char MenuItem itemChart = menu.findItem(R.id.menu_chart); if (itemChart != null) { Activity activity = getActivity(); if (activity instanceof IncomeVsExpensesActivity) { itemChart.setVisible(!((IncomeVsExpensesActivity) activity).mIsDualPanel); }/*from w ww .j a v a 2 s. c o m*/ } }
From source file:com.ichi2.anki.Reviewer.java
@SuppressLint("NewApi") @Override// w ww . jav a2s . com public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.reviewer, menu); Resources res = getResources(); if (mCurrentCard != null && mCurrentCard.note().hasTag("marked")) { menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_unmark_note) .setIcon(R.drawable.ic_star_white_24dp); } else { menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_mark_note) .setIcon(R.drawable.ic_star_outline_white_24dp); } if (colIsOpen() && getCol().undoAvailable()) { menu.findItem(R.id.action_undo).setEnabled(true).getIcon().setAlpha(Themes.ALPHA_ICON_ENABLED_LIGHT); } else { menu.findItem(R.id.action_undo).setEnabled(false).getIcon().setAlpha(Themes.ALPHA_ICON_DISABLED_LIGHT); } if (mPrefWhiteboard) { // Don't force showing mark icon when whiteboard enabled // TODO: allow user to customize which icons are force-shown MenuItemCompat.setShowAsAction(menu.findItem(R.id.action_mark_card), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); // Check if we can forceably squeeze in 3 items into the action bar, if not hide "show whiteboard" if (CompatHelper.getSdkVersion() >= 14 && !ViewConfiguration.get(this).hasPermanentMenuKey()) { // Android 4.x device with overflow menu in the action bar and small screen can't // support forcing 2 extra items into the action bar Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); float density = getResources().getDisplayMetrics().density; float dpWidth = outMetrics.widthPixels / density; if (dpWidth < 360) { menu.findItem(R.id.action_hide_whiteboard).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } // Configure the whiteboard related items in the action bar menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.disable_whiteboard); menu.findItem(R.id.action_hide_whiteboard).setVisible(true); menu.findItem(R.id.action_clear_whiteboard).setVisible(true); Drawable whiteboardIcon = getResources().getDrawable(R.drawable.ic_gesture_white_24dp); if (mShowWhiteboard) { whiteboardIcon.setAlpha(255); menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon); menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.hide_whiteboard); } else { whiteboardIcon.setAlpha(77); menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon); menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.show_whiteboard); } } else { menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.enable_whiteboard); } if (!CompatHelper.isHoneycomb() && !mDisableClipboard) { menu.findItem(R.id.action_search_dictionary).setVisible(true) .setEnabled(!(mPrefWhiteboard && mShowWhiteboard)) .setTitle(clipboardHasText() ? Lookup.getSearchStringTitle() : res.getString(R.string.menu_select)); } if (getCol().getDecks().isDyn(getParentDid())) { menu.findItem(R.id.action_open_deck_options).setVisible(false); } return super.onCreateOptionsMenu(menu); }
From source file:com.krayzk9s.imgurholo.ui.AlbumsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT) .equals(MainActivity.HOLO_LIGHT)) inflater.inflate(R.menu.main, menu); else// w ww .ja va 2 s.co m inflater.inflate(R.menu.main_dark, menu); if (username.equals("me")) menu.findItem(R.id.action_new).setVisible(true); menu.findItem(R.id.action_upload).setVisible(false); menu.findItem(R.id.action_refresh).setVisible(true); }
From source file:com.streaming.sweetplayer.PlayerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.player_options_menu, menu); inflater.inflate(R.menu.share_menu, menu); MenuItem shareItem = menu.findItem(R.id.item_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem); mShareActionProvider.setShareIntent(getDefaultIntent()); //mShareActionProvider.setShareHistoryFileName(null); MenuItem viewLyricsMenuItem = menu.findItem(R.id.item_view_lyrics); if (viewLyricsMenuItem != null) { viewLyricsMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { if (PlayerService.checkSongsList()) { new GetSongDetailTask().execute(); }//from ww w. j ava 2 s . c o m return true; } }); } mAddMenuItem = menu.findItem(R.id.item_add_to_playlist); if (mDataBase.isOnPlayList(sSongId)) { mAddMenuItem.setVisible(false); } else { mAddMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { addToPlaylist(); return true; } }); } return super.onCreateOptionsMenu(menu); }
From source file:com.example.castCambot.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.main, menu); MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item); MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat .getActionProvider(mediaRouteMenuItem); // Set the MediaRouteActionProvider selector for device discovery. mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector); return true;//from w w w . j ava 2s . c om }
From source file:at.bitfire.davdroid.ui.AccountActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem itemRename = menu.findItem(R.id.rename_account); // renameAccount is available for API level 21+ itemRename.setVisible(Build.VERSION.SDK_INT >= 21); return super.onPrepareOptionsMenu(menu); }