List of usage examples for android.view MenuItem setShowAsAction
public void setShowAsAction(int actionEnum);
From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java
public void getMenu(Menu menu) { if (parentFolder == null) { return;// w ww . j av a2 s .co m } if (getActivity() instanceof MainActivity) { getMenu(alfSession, menu, parentFolder); if (hasDocument()) { displayMenuItem = menu.add(Menu.NONE, MenuActionItem.MENU_DISPLAY_GALLERY, Menu.FIRST + MenuActionItem.MENU_DISPLAY_GALLERY, R.string.display_gallery); displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } else if (getActivity() instanceof PublicDispatcherActivity) { Permissions permission = alfSession.getServiceRegistry().getDocumentFolderService() .getPermissions(parentFolder); if (permission.canAddChildren()) { MenuItem mi = menu.add(Menu.NONE, MenuActionItem.MENU_CREATE_FOLDER, Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER, R.string.folder_create); mi.setIcon(R.drawable.ic_add_folder); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } // Uncomment for enabling view switcher /* * displayMenuItem = menu.add(Menu.NONE, * MenuActionItem.MENU_DISPLAY_ITEMS, Menu.FIRST + * MenuActionItem.MENU_DISPLAY_ITEMS, R.string.display_views); switch * (displayMode) { case DISPLAY_LIST: * displayMenuItem.setIcon(R.drawable.ic_action_list); break; case * DISPLAY_LIST_LARGE: * displayMenuItem.setIcon(R.drawable.ic_action_tiles_small); break; * case DISPLAY_GRID: * displayMenuItem.setIcon(R.drawable.ic_action_list_2); break; default: * break; } * displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); */ }
From source file:com.vishwa.pinit.MainActivity.java
@Override public boolean onSearchRequested() { if (mSearchMenuItem.isActionViewExpanded()) { mSearchMenuItem.collapseActionView(); return false; }/* w w w. j av a 2 s. c o 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:tw.com.geminihsu.app01.fragment.Fragment_Client_Service_test.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE, getString(R.string.order_call_taxi_page_title)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString);/*from w w w.j a v a 2s .com*/ Utility driver = new Utility(getActivity()); if (isShowOneKey && driver.getAllDriverAccountInfo().isEmpty()) item.setVisible(true); else item.setVisible(false); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java
private void prepareDownloadActionItem(MenuItem item, int downloadPercent) { item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); int dlRes = R.drawable.av_download; int removeRes = R.drawable.content_discard; switch (downloadPercent) { case PARAM_PROGRESS_DONE: videoIsDownloaded = true;/*from w w w .ja v a 2 s .c om*/ item.setEnabled(true).setTitle("Downloaded").setIcon(getResources().getDrawable(removeRes)); break; case PARAM_PROGRESS_UNKNOWN: if (video != null) { try { dataService.getHelper().getVideoDao().refresh(video); } catch (SQLException e) { e.printStackTrace(); } switch (video.getDownload_status()) { case Video.DL_STATUS_COMPLETE: videoIsDownloaded = true; item.setEnabled(true).setTitle("Downloaded").setIcon(getResources().getDrawable(removeRes)); break; case Video.DL_STATUS_IN_PROGRESS: videoIsDownloaded = false; item.setEnabled(false).setTitle("Downloading").setIcon(getResources().getDrawable(dlRes)); break; case Video.DL_STATUS_NOT_STARTED: default: videoIsDownloaded = false; item.setEnabled(true).setTitle("Download").setIcon(getResources().getDrawable(dlRes)); } } break; default: videoIsDownloaded = false; item.setEnabled(false).setTitle(downloadPercent + "%").setIcon(null); } }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // ??// w w w.j av a 2 s . co m MenuItem actionItem = menu.add(Menu.NONE, MENU_ID.SETTING.ordinal(), MENU_ID.SETTING.ordinal(), this.getString(R.string.menu_title_setting)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.SETTING.getDrawableResId()); // Twitter? actionItem = menu.add(Menu.NONE, MENU_ID.TWITTER.ordinal(), MENU_ID.TWITTER.ordinal(), this.getString(R.string.menu_title_share)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.TWITTER.getDrawableResId()); // Facebook actionItem = menu.add(Menu.NONE, MENU_ID.FACEBOOK.ordinal(), MENU_ID.FACEBOOK.ordinal(), this.getString(R.string.menu_title_facebook)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.FACEBOOK.getDrawableResId()); if (enableNewFunction) { // HISTORY actionItem = menu.add(Menu.NONE, MENU_ID.HISTORY.ordinal(), MENU_ID.HISTORY.ordinal(), this.getString(R.string.menu_title_history)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); actionItem.setIcon(MENU_ID.HISTORY.getDrawableResId()); } // LINE actionItem = menu.add(Menu.NONE, MENU_ID.LINE.ordinal(), MENU_ID.LINE.ordinal(), this.getString(R.string.menu_title_line)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(MENU_ID.LINE.getDrawableResId()); // FEEDBACK actionItem = menu.add(Menu.NONE, MENU_ID.FEEDBACK.ordinal(), MENU_ID.FEEDBACK.ordinal(), this.getString(R.string.menu_title_feedback)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); actionItem.setIcon(MENU_ID.FEEDBACK.getDrawableResId()); // LICENSE actionItem = menu.add(Menu.NONE, MENU_ID.LICENSE.ordinal(), MENU_ID.LICENSE.ordinal(), this.getString(R.string.menu_title_license)); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); actionItem.setIcon(MENU_ID.LICENSE.getDrawableResId()); return true; }
From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpAirPlane.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_SUMMIT, Menu.NONE, getString(R.string.menu_take)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString);//from w ww .j a v a 2s . c om item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
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//from ww w . j ava2s. co 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.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java
public void getMenu(Menu menu) { if (parentFolder == null) { return;/*from w w w.j a v a2s.c o m*/ } if (getActivity() instanceof MainActivity) { getMenu(getSession(), menu, parentFolder); if (hasDocument()) { displayMenuItem = menu.add(Menu.NONE, R.id.menu_gallery, Menu.FIRST, R.string.display_gallery); displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } else if (getActivity() instanceof PublicDispatcherActivity || getActivity() instanceof BaseShortcutActivity) { // permission = // getSession().getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder); if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, ConfigurableActionHelper.ACTION_CREATE_FOLDER)) { MenuItem mi = menu.add(Menu.NONE, R.id.menu_create_folder, Menu.FIRST, R.string.folder_create); mi.setIcon(R.drawable.ic_repository_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } MenuFragmentHelper.getMenu(getActivity(), menu); }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
@Override public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { SubMenu subMenuBlueTooth = menu.addSubMenu(this.getString(R.string.lblBluetoothItem)); com.actionbarsherlock.view.MenuItem miBluetooth = subMenuBlueTooth.getItem(); miBluetooth.setIcon(R.drawable.stat_sys_data_bluetooth); miBluetooth.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); com.actionbarsherlock.view.MenuItem miBlueToothDiscover = subMenuBlueTooth .add(R.string.lblBluetoothDiscover).setIcon(R.drawable.ic_menu_allfriends); com.actionbarsherlock.view.MenuItem miBlueToothGetDiscoverable = subMenuBlueTooth .add(R.string.lblBluetoothGetDiscoverable).setIcon(android.R.drawable.ic_menu_myplaces); com.actionbarsherlock.view.MenuItem miBlueToothReceive = subMenuBlueTooth.add(R.string.lblBluetoothReceive) .setIcon(R.drawable.ic_menu_download); com.actionbarsherlock.view.MenuItem miBlueToothHelp = subMenuBlueTooth.add(R.string.lblBluetoothHelp) .setIcon(android.R.drawable.ic_menu_info_details); miBlueToothDiscover.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//from w w w . j av a 2 s. co m public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { if (isBluetoothActivated()) { GameSetHistoryActivity.this.bluetoothHelper.startDiscovery(); AuditHelper.auditEvent(AuditHelper.EventTypes.actionBluetoothDiscoverDevices); } return true; } }); miBlueToothGetDiscoverable.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { if (isBluetoothActivated()) { GameSetHistoryActivity.this.bluetoothHelper.setBluetoothDeviceDiscoverable(); AuditHelper.auditEvent(AuditHelper.EventTypes.actionBluetoothSetDiscoverable); } return true; } }); miBlueToothReceive.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { if (isBluetoothActivated()) { // retrieve game count int gameSetCount; try { gameSetCount = AppContext.getApplication().getDalService().getGameSetCount(); } catch (DalException de) { gameSetCount = 0; } // prevent user from downloading if game set count > 5 and // limited version if (AppContext.getApplication().isAppLimited() && gameSetCount >= 5) { Toast.makeText(GameSetHistoryActivity.this, AppContext.getApplication().getResources() .getString(R.string.msgLimitedVersionInformation), Toast.LENGTH_SHORT).show(); } // ok for download else { try { GameSetHistoryActivity.this.receiveGameSetTask = new ReceiveGameSetTask( GameSetHistoryActivity.this, GameSetHistoryActivity.this.progressDialog, GameSetHistoryActivity.this.bluetoothHelper.getBluetoothAdapter()); GameSetHistoryActivity.this.receiveGameSetTask.setCallback(refreshCallback); GameSetHistoryActivity.this.receiveGameSetTask.execute(); AuditHelper.auditEvent(AuditHelper.EventTypes.actionBluetoothReceiveGameSet); } catch (IOException ioe) { Log.v(AppContext.getApplication().getAppLogTag(), "TarotDroid Exception in " + this.getClass().toString(), ioe); Toast.makeText(GameSetHistoryActivity.this, AppContext.getApplication().getResources() .getString(R.string.msgBluetoothError, ioe), Toast.LENGTH_SHORT).show(); } } } return true; } }); miBlueToothHelp.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { UIHelper.showSimpleRichTextDialog(GameSetHistoryActivity.this, AppContext.getApplication().getResources().getText(R.string.msgHelpBluetooth).toString(), AppContext.getApplication().getResources().getString(R.string.titleHelpBluetooth)); return true; } }); // TODO Improve Massive excel export // if (!AppContext.getApplication().isAppLimited()) { // com.actionbarsherlock.view.MenuItem miGlobalExport = // menu.add(this.getString(R.string.lblExcelExport)).setIcon(R.drawable.ic_excel); // miGlobalExport.setShowAsAction(com.actionbarsherlock.view.MenuItem.SHOW_AS_ACTION_NEVER); // //miGlobalExport.setIcon(R.drawable.ic_excel); // // miGlobalExport.setOnMenuItemClickListener(new // OnMenuItemClickListener() { // @Override // public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem // item) { // ExportToExcelTask task = new // ExportToExcelTask(GameSetHistoryActivity.this, progressDialog); // task.execute(); // return true; // } // }); // } com.actionbarsherlock.view.MenuItem miBin = menu.add(this.getString(R.string.lblInitDalItem)); miBin.setShowAsAction(com.actionbarsherlock.view.MenuItem.SHOW_AS_ACTION_NEVER); miBin.setIcon(R.drawable.gd_action_bar_trashcan); miBin.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.titleReinitDalYesNo)); builder.setMessage( Html.fromHtml(GameSetHistoryActivity.this.getText(R.string.msgReinitDalYesNo).toString())); builder.setPositiveButton(GameSetHistoryActivity.this.getString(R.string.btnOk), GameSetHistoryActivity.this.removeAllGameSetsDialogClickListener); builder.setNegativeButton(GameSetHistoryActivity.this.getString(R.string.btnCancel), GameSetHistoryActivity.this.removeAllGameSetsDialogClickListener).show(); builder.setIcon(android.R.drawable.ic_dialog_alert); return true; } }); return true; }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); try {/*from ww w . j a v a2 s.c o 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; }