List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:com.dwdesign.tweetings.fragment.SearchTweetsFragment.java
@Override public void onPrepareOptionsMenu(final Menu menu) { super.onPrepareOptionsMenu(menu); optionsMenu = menu;/*from ww w . ja va2 s . c om*/ final MenuItem itemSave = menu.findItem(MENU_SAVE); final MenuItem itemDelete = menu.findItem(MENU_DELETE_SUBMENU); if (mSearchId > 0) { itemSave.setVisible(false); itemDelete.setVisible(true); } else { itemSave.setVisible(true); itemDelete.setVisible(false); } }
From source file:com.example.android.bluetoothchat.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem logToggle = menu.findItem(R.id.menu_toggle_log); logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator); logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log); return super.onPrepareOptionsMenu(menu); }
From source file:atv.com.project.monkeylivetv.Activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // menu.clear(); getMenuInflater().inflate(R.menu.main_menu, menu); //Share//from ww w . jav a2 s . c o m MenuItem menuItem = menu.findItem(R.id.action_share); shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); setShareIntent(createShareIntent()); //Search MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(this); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo( searchManager.getSearchableInfo(new ComponentName(this, SearchableActivity.class))); searchView.setIconifiedByDefault(false); return true; }
From source file:com.example.shiwangi.dataplan.ScreenSlideActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.activity_screen_slide, menu); menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0); // Add either a "next" or "finish" button to the action bar, depending on which page // is currently selected. MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE, (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish : R.string.action_next); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true;/*from w w w.jav a 2s .c o m*/ }
From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { Log.v(TAG, "onPrepareOptionsMenu"); super.onPrepareOptionsMenu(menu); MenuItem prev = menu.findItem(R.id.action_prev); MenuItem next = menu.findItem(R.id.action_next); prev.setVisible(true);//from w w w . j av a 2s .co m next.setVisible(true); if (mPoemPagerAdapter != null) { prev.setEnabled(mViewPager.getCurrentItem() > 0); next.setEnabled(mViewPager.getCurrentItem() < mPoemPagerAdapter.getCount() - 1); } final View view = menu.findItem(R.id.action_share).getActionView(); ActionBar.hackSetMaxHeight(view, getActionBar().getHeight()); return true; }
From source file:android.hawkencompanionapp.activities.BaseActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.login, menu); final MenuItem menuItemSignOut = menu.findItem(R.id.action_sign_out); final MenuItem menuItemOfflineMode = menu.findItem(R.id.action_offline_mode); //Disable the About option if the current activity is the About activity if (this instanceof AboutActivity) { final MenuItem about = menu.findItem(R.id.action_about); final int len = menu.size(); //Disable all menu items when the about activity is being shown. for (int i = 0; i < len; i++) { final MenuItem item = menu.getItem(i); item.setVisible(false);/*from w w w.j av a 2 s .c om*/ } } else if (this instanceof ForgotPasswordActvity) { //Forgot Password activity is shown menuItemSignOut.setVisible(false); menuItemOfflineMode.setVisible(false); } else if (this instanceof LoginActivity) { //Login activity is shown menuItemSignOut.setVisible(false); } else if (this instanceof UserAccountMainActivity) { menuItemOfflineMode.setVisible(false); } if (mDisableSignOutOption) { //If the user is in offline mode menuItemSignOut.setVisible(false); } return true; }
From source file:com.achep.acdisplay.ui.activities.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); mSendTestNotificationMenuItem = menu.findItem(R.id.test_action); updateSendTestNotificationMenuItem(); return true;//w w w . j a v a 2s .c o m }
From source file:com.adkdevelopment.rssreader.ui.DetailFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_detail, menu); // Retrieve the share menu item MenuItem item = menu.findItem(R.id.share); // Get the provider and hold onto it to set/change the share intent. ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(mPresenter.getShareIntent()); } else {/*from w w w. j a va 2 s.c o m*/ Log.e(TAG, "fail to set a share intent"); } }
From source file:bbct.android.common.activity.BaseballCardList.java
@Override public void onPrepareOptionsMenu(Menu menu) { Log.d(TAG, "onPrepareOptionsMenu()"); MenuItem filter = menu.findItem(R.id.filter_menu); MenuItem clearFilter = menu.findItem(R.id.clear_filter_menu); if (this.filterParams == null) { filter.setVisible(true);// w w w . j ava 2s.com filter.setEnabled(true); clearFilter.setVisible(false); clearFilter.setEnabled(false); } else { filter.setVisible(false); filter.setEnabled(false); clearFilter.setVisible(true); clearFilter.setEnabled(true); } }
From source file:br.liveo.ndrawer.FragmentMain.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // TODO Auto-generated method stub super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu, menu); //Select search item final MenuItem menuItem = menu.findItem(R.id.menu_search); menuItem.setVisible(true);/* www. j av a 2 s . c om*/ SearchView searchView = (SearchView) menuItem.getActionView(); searchView.setQueryHint(this.getString(R.string.search)); ((EditText) searchView.findViewById(R.id.search_src_text)) .setHintTextColor(getResources().getColor(R.color.nliveo_white)); searchView.setOnQueryTextListener(onQuerySearchView); menu.findItem(R.id.menu_add).setVisible(true); mSearchCheck = false; }