List of usage examples for android.view MenuItem SHOW_AS_ACTION_IF_ROOM
int SHOW_AS_ACTION_IF_ROOM
To view the source code for android.view MenuItem SHOW_AS_ACTION_IF_ROOM.
Click Source Link
From source file:com.tweetlanes.android.core.view.BaseLaneActivity.java
void configureActionBarSearchView(Menu menu) { MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) searchItem.getActionView(); searchItem.setShowAsActionFlags(// w ww . jav a2 s . com MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchView.setOnQueryTextListener(this); OnFocusChangeListener onFocusChangeListener = new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { mCurrentComposeFragment.setIgnoreFocusChange(true); if (mComposeTweetView != null) { mComposeTweetView.setVisibility(View.GONE); } if (mComposeDirectMessageView != null) { mComposeDirectMessageView.setVisibility(View.GONE); } if (!hasFocus) { if (mCurrentComposeFragment == mComposeDirectMessageFragment) { if (mComposeDirectMessageView != null) { mComposeDirectMessageView.setVisibility(View.VISIBLE); } } else { if (mComposeTweetView != null) { mComposeTweetView.setVisibility(View.VISIBLE); } } } mCurrentComposeFragment.setIgnoreFocusChange(false); } }; searchView.setOnQueryTextFocusChangeListener(onFocusChangeListener); searchView.setOnFocusChangeListener(onFocusChangeListener); }
From source file:com.vishwa.pinit.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_search: final MenuItem createNoteItem = mMenu.getItem(1); createNoteItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); item.setOnActionExpandListener(new OnActionExpandListener() { @Override// ww w . j a v a 2 s . c o m public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { createNoteItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return true; } }); break; case R.id.action_create_note: mMapEditMode = MapEditMode.CREATE_NOTE; hideNoteEditButtons(); mMenu.findItem(R.id.action_create_note).setVisible(false); mMenu.findItem(R.id.action_cancel).setVisible(true).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); Toast.makeText(getApplicationContext(), "Press and hold the location where you'd like to create a note", Toast.LENGTH_SHORT).show(); break; case R.id.action_logout: if (ParseFacebookUtils.getSession() != null) { ParseFacebookUtils.getSession().closeAndClearTokenInformation(); } ParseUser.logOut(); finish(); break; case R.id.action_refresh: if (!PinItUtils.isOnline(getApplicationContext())) { PinItUtils.createAlert("Internet connection not found.", "Connect to the Internet and press the refresh button at the top", this); mHasInternet = false; hideNonRefreshMenuItems(); } else { mHasInternet = true; showNonRefreshMenuItems(); loadMapWhenOnline(); mMap.getUiSettings().setAllGesturesEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(true); mMap.getUiSettings().setZoomGesturesEnabled(true); } break; case R.id.action_edit_location: if (mFocusedMarker != null) { Toast.makeText(getApplicationContext(), "Press and hold the current note and then drag it to where " + "you'd like to position it and click save", Toast.LENGTH_LONG).show(); mMenu.findItem(R.id.action_save).setVisible(true); mMenu.findItem(R.id.action_cancel).setVisible(true); mMenu.findItem(R.id.action_create_note).setVisible(false); mMenu.findItem(R.id.action_search).setVisible(false); mMenu.findItem(R.id.action_edit).setVisible(false); for (Marker marker : mMarkerList) { marker.setDraggable(false); } mFocusedMarker.setDraggable(true); } else { Toast.makeText(getApplicationContext(), "Please click on the note you'd like " + "to move and then try again", Toast.LENGTH_SHORT) .show(); } break; case R.id.action_save: if (mHasInternet) { setProgressBarIndeterminateVisibility(true); ParseQuery query = new ParseQuery("Note"); query.getInBackground(mNoteStore.get(mFocusedMarker.getId()).getNoteId(), new GetCallback() { public void done(ParseObject object, ParseException e) { if (e == null) { ParseGeoPoint geopoint = new ParseGeoPoint(mFocusedMarker.getPosition().latitude, mFocusedMarker.getPosition().longitude); object.put("geopoint", geopoint); object.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { setProgressBarIndeterminateVisibility(false); mFocusedMarker.setDraggable(false); hideNoteEditButtons(); mMenu.findItem(R.id.action_edit).setVisible(true); Toast.makeText(getApplicationContext(), "Note location updated!", Toast.LENGTH_LONG).show(); } else { PinItUtils.createAlert("This note could not be updated.", "We apologize, this note update failed, please try again", MainActivity.this); } } }); } else { PinItUtils.createAlert("This note could not be updated.", "We apologize, this note update failed, please try again", MainActivity.this); } } }); } break; case R.id.action_delete_note: if (mFocusedMarker != null) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setTitle("Are you sure?"); dialog.setMessage("Please confirm that you'd like to delete this note."); dialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { final Note note = mNoteStore.get(mFocusedMarker.getId()); ParseQuery query = new ParseQuery("Note"); query.getInBackground(note.getNoteId(), new GetCallback() { @Override public void done(ParseObject object, ParseException e) { if (e == null) { object.deleteInBackground(new DeleteCallback() { @Override public void done(ParseException e) { if (e == null) { Toast.makeText(getApplicationContext(), "Note deleted!", Toast.LENGTH_SHORT).show(); if (mFocusedMarker != null) { mNoteStore.remove(mFocusedMarker.getId()); mReverseNoteStore.remove(note.getNoteId()); Iterator<Marker> iterator = mMarkerList.iterator(); while (iterator.hasNext()) { Marker marker = iterator.next(); if (marker.getId().equals(mFocusedMarker.getId())) { mFocusedMarker.remove(); mFocusedMarker = null; iterator.remove(); break; } } hideNoteEditButtons(); } } } }); } else { PinItUtils.createAlert("Something's gone wrong", "Please try deleting the note again", MainActivity.this); } } }); } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }); dialog.show(); } break; case R.id.action_edit_note: if (mFocusedMarker != null) { Note note = mNoteStore.get(mFocusedMarker.getId()); Intent intent = new Intent(this, EditNoteActivity.class); intent.putExtra("note", note); startActivityForResult(intent, REQUEST_CODE_EDIT_NOTE); } else { Toast.makeText(getApplicationContext(), "Please click on the note you'd like " + "to edit and then try again", Toast.LENGTH_SHORT) .show(); } break; case R.id.action_cancel: if (mFocusedMarker != null) { double latitude = mNoteStore.get(mFocusedMarker.getId()).getNoteLatitude(); double longitude = mNoteStore.get(mFocusedMarker.getId()).getNoteLongitude(); LatLng geopoint = new LatLng(latitude, longitude); mFocusedMarker.setPosition(geopoint); mFocusedMarker.setDraggable(false); mFocusedMarker.hideInfoWindow(); } if (mMapEditMode == MapEditMode.CREATE_NOTE) { mMapEditMode = MapEditMode.DEFAULT_MODE; } hideNoteEditButtons(); break; case R.id.action_settings: Intent settingsIntent = new Intent(this, SettingsActivity.class); startActivityForResult(settingsIntent, REQUEST_CODE_CHANGE_SETTINGS); break; case R.id.action_about: Intent intent = new Intent(this, AboutActivity.class); startActivity(intent); break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM; MenuItem item;/*from w ww .ja v a 2 s .c o m*/ if (currentFragment != ScreenList.WEBKIT) { ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE); actionBar.show(); item = menu.add(Menu.NONE, MENU_FILL_FORM, Menu.NONE, getString(R.string.enter_data_button)); item.setIcon(R.drawable.ic_action_collections_collection).setShowAsAction(showOption); // Using a file for this work now String get = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_GET_BLANK); if (get.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_PULL_FORMS, Menu.NONE, getString(R.string.get_forms)); item.setIcon(R.drawable.ic_action_av_download).setShowAsAction(showOption); item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, getString(R.string.get_forms)); item.setIcon(R.drawable.ic_action_cloud).setShowAsAction(showOption); } String send = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_SEND_FINALIZED); if (send.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_PUSH_FORMS, Menu.NONE, getString(R.string.send_data)); item.setIcon(R.drawable.ic_action_av_upload).setShowAsAction(showOption); } String manage = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_MANAGE_FORMS); if (manage.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_MANAGE_FORMS, Menu.NONE, getString(R.string.manage_files)); item.setIcon(R.drawable.trash).setShowAsAction(showOption); } String settings = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_ACCESS_SETTINGS); if (settings.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_PREFERENCES, Menu.NONE, getString(R.string.general_preferences)); item.setIcon(R.drawable.ic_menu_preferences).setShowAsAction(showOption); } item = menu.add(Menu.NONE, MENU_ADMIN_PREFERENCES, Menu.NONE, getString(R.string.admin_preferences)); item.setIcon(R.drawable.ic_action_device_access_accounts).setShowAsAction(showOption); item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, getString(R.string.about)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } else { ActionBar actionBar = getActionBar(); actionBar.hide(); } return true; }
From source file:com.android.settings.applications.CanBeOnSdCardChecker.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { mOptionsMenu = menu;/*from w ww . j a v a 2s.c om*/ // note: icons removed for now because the cause the new action // bar UI to be very confusing. menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha) //.setIcon(android.R.drawable.ic_menu_sort_alphabetically) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size) //.setIcon(android.R.drawable.ic_menu_sort_by_size) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, SHOW_RUNNING_SERVICES, 3, R.string.show_running_services) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, SHOW_BACKGROUND_PROCESSES, 3, R.string.show_background_processes) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, RESET_APP_PREFERENCES, 4, R.string.reset_app_preferences) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (!Utils.isRestrictedProfile(getActivity())) { menu.add(0, SHOW_PROTECTED_APPS, 5, R.string.protected_apps) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } updateOptionsMenu(); }
From source file:org.alfresco.mobile.android.application.fragments.properties.DetailsFragment.java
public static void getMenu(AlfrescoSession session, Activity activity, Menu menu, Node node, boolean actionMode) { MenuItem mi;// w w w . j a v a 2 s . c o m if (node == null) { return; } if (node instanceof NodeSyncPlaceHolder) { return; } boolean isRestrict = node.hasAspect(ContentModel.ASPECT_RESTRICTABLE); if (node.isDocument()) { if (((Document) node).getContentStreamLength() > 0 && !isRestrict) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_DOWNLOAD, Menu.FIRST + MenuActionItem.MENU_DOWNLOAD, R.string.download); mi.setIcon(R.drawable.ic_download_dark); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (((Document) node).isLatestVersion() && ((DocumentImpl) node).hasAllowableAction(Action.CAN_SET_CONTENT_STREAM.value())) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_UPDATE, Menu.FIRST + MenuActionItem.MENU_UPDATE, R.string.update); mi.setIcon(R.drawable.ic_upload); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!(session instanceof CloudSession)) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_WORKFLOW_ADD, Menu.FIRST + MenuActionItem.MENU_WORKFLOW_ADD, R.string.process_start_review); mi.setIcon(R.drawable.ic_start_review); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } if (session.getServiceRegistry().getDocumentFolderService().getPermissions(node).canEdit()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_EDIT, Menu.FIRST + MenuActionItem.MENU_EDIT, R.string.edit); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (session.getServiceRegistry().getDocumentFolderService().getPermissions(node).canDelete()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_DELETE, 1000 + MenuActionItem.MENU_DELETE, R.string.delete); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!DisplayUtils.hasCentralPane(activity)) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMMENT, Menu.FIRST + MenuActionItem.MENU_COMMENT, R.string.comments); mi.setIcon(R.drawable.ic_comment); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); if (node.isDocument()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_VERSION_HISTORY, Menu.FIRST + MenuActionItem.MENU_VERSION_HISTORY, R.string.version_history); mi.setIcon(R.drawable.ic_menu_recent_history); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } mi = menu.add(Menu.NONE, MenuActionItem.MENU_TAGS, Menu.FIRST + MenuActionItem.MENU_TAGS, R.string.tags); mi.setIcon(R.drawable.mime_tags); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } }
From source file:org.path.episample.android.activities.MainMenuActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM; MenuItem item;//from w w w. j ava2s . co m if (currentFragment != ScreenList.WEBKIT) { ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE); actionBar.show(); item = menu.add(Menu.NONE, MENU_MAIN_MENU, Menu.NONE, getString(R.string.main_menu)); item.setIcon(R.drawable.ic_action_home).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); //item = menu.add(Menu.NONE, MENU_FILL_FORM, Menu.NONE, getString(R.string.enter_data_button)); //item.setIcon(R.drawable.ic_action_collections_collection).setShowAsAction(showOption); // Using a file for this work now String get = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_GET_BLANK); if (get.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_PULL_FORMS, Menu.NONE, getString(R.string.get_forms)); item.setIcon(R.drawable.ic_action_av_download).setShowAsAction(showOption); //item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, getString(R.string.get_forms)); //item.setIcon(R.drawable.ic_action_cloud).setShowAsAction(showOption); } String send = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_SEND_FINALIZED); if (send.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_PUSH_FORMS, Menu.NONE, getString(R.string.send_data)); item.setIcon(R.drawable.ic_action_av_upload).setShowAsAction(showOption); } String manage = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_MANAGE_FORMS); if (manage.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_MANAGE_FORMS, Menu.NONE, getString(R.string.manage_files)); item.setIcon(R.drawable.trash).setShowAsAction(showOption); } String settings = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_ACCESS_SETTINGS); if (settings.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_PREFERENCES, Menu.NONE, getString(R.string.general_preferences)); item.setIcon(R.drawable.ic_menu_preferences).setShowAsAction(showOption); } item = menu.add(Menu.NONE, MENU_ADMIN_PREFERENCES, Menu.NONE, getString(R.string.admin_preferences)); item.setIcon(R.drawable.ic_action_device_access_accounts).setShowAsAction(showOption); String backup = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_BACKUP_CENSUS); if (backup != null && backup.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_BACKUP_CENSUS, Menu.NONE, getString(R.string.backup_census)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } String restore = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_RESTORE_CENSUS); if (restore != null && restore.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_RESTORE_CENSUS, Menu.NONE, getString(R.string.restore_census)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } String invalidateCensus = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_INVALIDATE_CENSUS); if (invalidateCensus != null && invalidateCensus.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_MARK_CENSUS_AS_INVALID, Menu.NONE, getString(R.string.invalidate_census)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } String edit = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_EDIT_CENSUS); if (edit != null && edit.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_EDIT_CENSUS, Menu.NONE, getString(R.string.edit_census)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } String removeCensus = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_REMOVE_CENSUS); if (removeCensus != null && removeCensus.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_REMOVE_CENSUS, Menu.NONE, getString(R.string.remove_census)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } /*String send_receive_bt = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_SEND_RECEIVE_BLUETOOTH); if (send_receive_bt != null && send_receive_bt.equalsIgnoreCase("true")) { item = menu.add(Menu.NONE, MENU_SEND_REVEIVE_BLUETOOTH, Menu.NONE, getString(R.string.send_receive_bluetooth)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); }*/ item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, getString(R.string.about)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } else { ActionBar actionBar = getActionBar(); actionBar.hide(); } return true; }
From source file:org.alfresco.mobile.android.application.fragments.node.details.NodeDetailsFragment.java
public void getMenu(Context context, AlfrescoSession session, Menu menu, Node node) { MenuItem mi;/* ww w. j av a 2s. c o m*/ if (node == null) { return; } if (node instanceof NodeSyncPlaceHolder) { return; } boolean isRestrict = node.hasAspect(ContentModel.ASPECT_RESTRICTABLE); if (node.isDocument()) { if (((Document) node).getContentStreamLength() > 0 && !isRestrict && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_DOWNLOAD)) { mi = menu.add(Menu.NONE, R.id.menu_action_download, Menu.FIRST, R.string.download); mi.setIcon(R.drawable.ic_download_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (((Document) node).isLatestVersion() && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_UPDATE)) { mi = menu.add(Menu.NONE, R.id.menu_action_update, Menu.FIRST + 130, R.string.update); mi.setIcon(R.drawable.ic_upload); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!(session instanceof CloudSession) && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_REVIEW)) { mi = menu.add(Menu.NONE, R.id.menu_workflow_add, Menu.FIRST + 500, R.string.process_start_review); mi.setIcon(R.drawable.ic_start_review); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } if (session == null) { return; } if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_EDIT)) { mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 10, R.string.edit); mi.setIcon(R.drawable.ic_properties); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (node.hasAspect(ContentModel.ASPECT_GEOGRAPHIC)) { mi = menu.add(Menu.NONE, R.id.menu_action_location, Menu.FIRST + 50, R.string.geolocation); mi.setIcon(R.drawable.ic_location); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_DELETE)) { mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } }
From source file:org.uguess.android.sysinfo.SiragonManager.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem mi = menu.add(Menu.NONE, MI_REFRESH, Menu.NONE, R.string.refresh); mi.setIcon(android.R.drawable.ic_menu_rotate); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_IF_ROOM); /*mi = menu.add( Menu.NONE, MI_ABOUT, Menu.NONE, R.string.about ); mi.setIcon( android.R.drawable.ic_menu_info_details ); Util.setShowAsAction( mi, MenuItem.SHOW_AS_ACTION_NEVER ); //www . ja v a 2 s .c o m mi = menu.add( Menu.NONE, MI_HELP, Menu.NONE, R.string.help ); mi.setIcon( android.R.drawable.ic_menu_help ); Util.setShowAsAction( mi, MenuItem.SHOW_AS_ACTION_NEVER );*/ mi = menu.add(Menu.NONE, MI_PREFERENCE, Menu.NONE, R.string.preference); mi.setIcon(android.R.drawable.ic_menu_preferences); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_NEVER); mi = menu.add(Menu.NONE, MI_EXIT, Menu.NONE, R.string.exit); mi.setIcon(android.R.drawable.ic_menu_close_clear_cancel); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_NEVER); }
From source file:com.vishwa.pinit.MainActivity.java
@Override public boolean onSearchRequested() { if (mSearchMenuItem.isActionViewExpanded()) { mSearchMenuItem.collapseActionView(); return false; }/* w w w .java 2 s. co m*/ final MenuItem createNoteItem = mMenu.getItem(1); createNoteItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mSearchMenuItem.expandActionView(); mSearchMenuItem.setOnActionExpandListener(new OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { createNoteItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return true; } }); return false; }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); try {/*from w w w . j a v a 2s .co m*/ 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); item.setIcon(R.drawable.ic_menu_forward); MenuItem stepItem = menu.add(Menu.NONE, R.id.action_step_ten, Menu.NONE, step10 ? R.string.action_step_ten : R.string.action_step_one); stepItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem turn_on_flash_Item = menu.add(Menu.NONE, R.id.action_turn_on_flash, Menu.NONE, R.string.action_turn_on_light); turn_on_flash_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); turn_on_flash_Item.setIcon(R.drawable.ic_menu_flashlight); MenuItem filter_Item = menu.add(Menu.NONE, R.id.action_filter, Menu.NONE, R.string.filter); filter_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); filter_Item.setIcon(R.drawable.filter); MenuItem search_Item = menu.add(Menu.NONE, R.id.action_search, Menu.NONE, R.string.search); search_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem addCustomer_Item = menu.add(Menu.NONE, R.id.action_new_customer, Menu.NONE, R.string.new_customer); addCustomer_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); setTitle(); progressbar.setProgress(mPager.getCurrentItem() + 1); progressbar.setMax(mPagerAdapter.getCount()); final Handler handler = new Handler(); progressbar.setVisibility(View.VISIBLE); handler.postDelayed(new Runnable() { @Override public void run() { callCount--; if (callCount <= 0) { progressbar.setVisibility(View.GONE); } } }, 3000); callCount++; } catch (Exception ex) { ex.toString(); } return true; }