List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:com.scigames.registration.LoginActivity.java
/** * Called right before your activity's option menu is displayed. *//*from w w w .j ava2 s . c o m*/ @Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); // Before showing the menu, we need to decide whether the clear // item is enabled depending on whether there is text to clear. menu.findItem(CLEAR_ID).setVisible(firstName.getText().length() > 0); menu.findItem(CLEAR_ID).setVisible(lastName.getText().length() > 0); menu.findItem(CLEAR_ID).setVisible(password.getText().length() > 0); menu.findItem(CLEAR_ID).setVisible(classId.getText().length() > 0); return true; }
From source file:com.senior.chromecastcheckers.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. ja v a 2s .com*/ }
From source file:com.dwdesign.tweetings.fragment.BaseStatusesListFragment.java
public void openMenu(View view, ParcelableStatus status) { mPopupMenu = PopupMenu.getInstance(getActivity(), view); mPopupMenu.inflate(R.menu.action_status); final int activated_color = getResources().getColor(R.color.holo_blue_bright); final boolean click_to_open_menu = mPreferences.getBoolean(PREFERENCE_KEY_CLICK_TO_OPEN_MENU, false); final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null); final Menu menu = mPopupMenu.getMenu(); final MenuItem itemView = menu.findItem(MENU_VIEW); if (itemView != null) { itemView.setVisible(click_to_open_menu); }//from w ww. j a v a 2 s . com final MenuItem direct_retweet = menu.findItem(MENU_RETWEET); if (direct_retweet != null) { final Drawable icon = direct_retweet.getIcon().mutate(); direct_retweet.setVisible( (!status.is_protected && status.account_id != status.user_id) || isMyRetweet(status)); if (isMyRetweet(status)) { icon.setColorFilter(activated_color, PorterDuff.Mode.MULTIPLY); direct_retweet.setTitle(R.string.cancel_retweet); } else { icon.clearColorFilter(); direct_retweet.setTitle(R.string.retweet); } } final MenuItem bufferView = menu.findItem(MENU_ADD_TO_BUFFER); if (bufferView != null) { if (buffer_authorised != null && !buffer_authorised.equals("")) { bufferView.setVisible(true); } else { bufferView.setVisible(false); } } setMenuForStatus(getActivity(), menu, status); mPopupMenu.setOnMenuItemClickListener(this); mPopupMenu.show(); }
From source file:ch.luklanis.esscan.history.HistoryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (mHistoryManager.hasHistoryItems()) { getMenuInflater().inflate(R.menu.history_menu, menu); SearchView searchView = (SearchView) menu.findItem(R.id.history_menu_search).getActionView(); searchView.setOnQueryTextListener(queryListener); MenuItem copyItem = menu.findItem(R.id.history_menu_copy_code_row); MenuItem sendItem = menu.findItem(R.id.history_menu_send_code_row); if (twoPane && this.historyFragment.getActivatedPosition() != ListView.INVALID_POSITION) { copyItem.setVisible(true);/*from ww w . ja v a2s .c o m*/ sendItem.setVisible(true); } else { copyItem.setVisible(false); sendItem.setVisible(false); } MenuItem item = menu.findItem(R.id.history_menu_send_dta); if (dtaFileCreator.getFirstErrorId() != 0) { item.setVisible(false); } return true; } return false; }
From source file:augsburg.se.alltagsguide.overview.OverviewActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.overview, menu); columnsMenu = menu.findItem(R.id.menu_columns); updateMenu();// w w w .ja v a 2 s . com MenuItem searchItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { if (mPageOverviewFragment != null) { mPageOverviewFragment.filterByText(newText); } if (mEventOverviewFragment != null) { mEventOverviewFragment.filterByText(newText); } return false; } }); return super.onCreateOptionsMenu(menu); }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { Log.v(TAG, "onPrepareOptionsMenu " + menu); // Only enable the "delete team" menu item if we have at least two teams. MenuItem deleteItem = menu.findItem(R.id.action_team_delete); deleteItem.setEnabled(mTeamCount > 1); // Add the current team name to the delete and rename menu items if (mTeam != null) { deleteItem.setTitle(getString(R.string.action_team_delete_name, mTeam.teamName)); MenuItem renameItem = menu.findItem(R.id.action_team_rename); renameItem.setTitle(getString(R.string.action_team_rename_name, mTeam.teamName)); }/*from w ww. ja v a 2 s .c om*/ // Only show the settings in v14+. Currently the only setting // we have is for the day/night theme switch, which only works on // v14+. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { MenuItem settingsItem = menu.findItem(R.id.action_settings); settingsItem.setVisible(false); } // Only show the menu items for sharing a meeting and stats for a meeting, if the selected meeting is finished. MeetingFragment meetingFragment = MeetingFragment.lookupMeetingFragment(getSupportFragmentManager()); boolean meetingIsFinished = meetingFragment != null && meetingFragment.getState() == MeetingColumns.State.FINISHED; MenuItem menuItem = menu.findItem(R.id.action_share_meeting); if (menuItem != null) menuItem.setVisible(meetingIsFinished); menuItem = menu.findItem(R.id.action_charts_meeting); if (menuItem != null) menuItem.setVisible(meetingIsFinished); // Don't show the global share/stats menu items unless we have at least one meeting MeetingsListFragment meetingsListFragment = (MeetingsListFragment) mMainPagerAdapter .instantiateItem(mBinding.pager, 0); boolean hasMeetings = meetingsListFragment != null && meetingsListFragment.hasMeetings(); menu.findItem(R.id.action_share).setVisible(hasMeetings); menu.findItem(R.id.action_charts).setVisible(hasMeetings); menuItem = menu.findItem(R.id.action_share_submenu); if (menuItem != null) menuItem.setVisible(hasMeetings); menuItem = menu.findItem(R.id.action_charts_submenu); if (menuItem != null) menuItem.setVisible(hasMeetings); return super.onPrepareOptionsMenu(menu); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadViewFragment.java
/** * Sets up the menu for the fragment./*from w w w . j a v a 2s. co m*/ * @param menu The Menu item for the fragment itself. * @param inflater The inflater for inflating the fragment's menu. */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Inflate the menu; this adds items to the action bar if it is present. inflater.inflate(R.menu.thread_view, menu); MenuItem item = menu.findItem(R.id.action_settings); item.setVisible(true); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.andrew.apollo.ui.activities.BaseActivity.java
/** * {@inheritDoc}//from w w w.j a v a 2 s. c o m */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getMenuInflater().inflate(R.menu.search, menu); // Settings getMenuInflater().inflate(R.menu.activity_base, menu); // Theme the search icon mResources.setSearchIcon(menu); final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); // Add voice search final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); searchView.setSearchableInfo(searchableInfo); // Perform the search searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(final String query) { // Open the search activity NavUtils.openSearch(BaseActivity.this, query); return true; } @Override public boolean onQueryTextChange(final String newText) { // Nothing to do return false; } }); return super.onCreateOptionsMenu(menu); }
From source file:android_network.hetnet.vpn_service.ActivityLog.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.logging, menu); menuSearch = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//ww w . j a v a2s . c o m public boolean onQueryTextSubmit(String query) { if (adapter != null) adapter.getFilter().filter(query); return true; } @Override public boolean onQueryTextChange(String newText) { if (adapter != null) adapter.getFilter().filter(newText); return true; } }); searchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { if (adapter != null) adapter.getFilter().filter(null); return true; } }); return true; }