List of usage examples for android.view MenuItem setShowAsAction
public void setShowAsAction(int actionEnum);
From source file:com.money.manager.ex.account.AccountTransactionListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); //force show add transaction MenuItem itemAddTransaction = menu.findItem(R.id.menu_add_transaction_account); if (itemAddTransaction != null) itemAddTransaction.setVisible(true); //manage dual panel if (getActivity() != null && getActivity() instanceof MainActivity) { MainActivity activity = (MainActivity) getActivity(); if (!activity.isDualPanel()) { //hide sync toolbar MenuItem itemSync = menu.findItem(R.id.menu_sync); if (itemSync != null) itemSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // hide menu open database MenuItem itemOpenDatabase = menu.findItem(R.id.menu_open_database); if (itemOpenDatabase != null) { //itemOpenDatabase.setVisible(isShownOpenDatabaseItemMenu()); itemOpenDatabase.setShowAsAction( !itemSync.isVisible() ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER); }/*from w w w .j a va 2 s. co m*/ //hide dash board MenuItem itemDashboard = menu.findItem(R.id.menu_dashboard); if (itemDashboard != null) itemDashboard.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } selectCurrentPeriod(menu); selectCurrentStatus(menu); }
From source file:gov.cdc.epiinfo.RecordList.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = new SearchView(this); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//from w w w . java 2 s .com public boolean onQueryTextSubmit(String searchTerm) { try { mDbHelper.fetchTopOne(); String query = BuildQuery(searchTerm); String fieldName1; String fieldName2; String fieldName3; String[] from = new String[1]; int[] to = new int[1]; if (formMetadata.DataFields.size() > 2) { fieldName1 = formMetadata.DataFields.get(0).getName(); fieldName2 = formMetadata.DataFields.get(1).getName(); fieldName3 = formMetadata.DataFields.get(2).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, fieldName3, query); from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2, "columnName3", fieldName3, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3, R.id.header4, R.id.text4, R.id.hiddenText }; } else if (formMetadata.DataFields.size() == 2) { fieldName1 = formMetadata.DataFields.get(0).getName(); fieldName2 = formMetadata.DataFields.get(1).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, query); from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3, R.id.hiddenText }; } else if (formMetadata.DataFields.size() == 1) { fieldName1 = formMetadata.DataFields.get(0).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, query); from = new String[] { "_id", "columnName1", fieldName1, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.hiddenText }; } startManagingCursor(mNotesCursor); CustomListAdapter notes = new CustomListAdapter(self, R.layout.line_list_row, mNotesCursor, from, to); lineListFragment.setListAdapter(notes); } catch (Exception ex) { fillData(); } return false; } @Override public boolean onQueryTextChange(String newText) { if (newText.equals("")) { fillData(); } return false; } }); mnuSearch = menu.add(0, SEARCH_ID, 0, R.string.menu_search); mnuSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); mnuSearch.setActionView(searchView); mnuSearch.setIcon(gov.cdc.epiinfo.R.drawable.action_search); MenuItem mnuQR = menu.add(0, QR_ID, 1, R.string.menu_barcode); mnuQR.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mnuQR.setIcon(gov.cdc.epiinfo.R.drawable.qrcode_scan); MenuItem mnuCloud = menu.add(0, CLOUD_ID, 2, R.string.menu_cloud_sync); mnuCloud.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem mnuSync = menu.add(0, SYNC_ID, 3, R.string.menu_sync_file); mnuSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem mnuDeleteAll = menu.add(0, DELETE_ALL_ID, 4, R.string.menu_delete_all); mnuDeleteAll.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (fkeyGuid == null || fkeyGuid.length() == 0) { mnuSetDefault = menu.add(0, SET_DEFAULT_ID, 5, R.string.set_default_form); mnuSetDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); mnuExitDefault = menu.add(0, EXIT_DEFAULT_MODE_ID, 5, R.string.exit_default_form); mnuExitDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (AppManager.getDefaultForm().equals("")) { mnuSetDefault.setVisible(true); mnuExitDefault.setVisible(false); } else { mnuSetDefault.setVisible(false); mnuExitDefault.setVisible(true); } } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPref.getString("cloud_service", "").equals("Box")) { mnuBoxSignin = menu.add(0, BOX_SIGNIN_ID, 6, R.string.box_signin); mnuBoxSignin.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); mnuBoxSignout = menu.add(0, BOX_SIGNOUT_ID, 6, R.string.box_signout); mnuBoxSignout.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (BoxClient.isAuthenticated(this)) { mnuBoxSignout.setVisible(true); mnuBoxSignin.setVisible(false); } else { mnuBoxSignout.setVisible(false); mnuBoxSignin.setVisible(true); } } MenuItem mnuHelp = menu.add(1, HELP_ID, 7, R.string.menu_help); mnuHelp.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true; }
From source file:com.vadimfrolov.duorem.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem miAdd = (MenuItem) menu.findItem(R.id.action_add_host); MenuItem miEdit = (MenuItem) menu.findItem(R.id.action_edit_host); MenuItem miDelete = (MenuItem) menu.findItem(R.id.action_delete_host); boolean targetIsValid = mTarget != null && ((mTarget.ipAddress != null && !mTarget.ipAddress.equals(NetInfo.NOIP)) || (mTarget.hardwareAddress != null && !mTarget.hardwareAddress.equals(NetInfo.NOMAC))); if (targetIsValid) { miAdd.setTitle(getResources().getString(R.string.replace_host)); } else {/*from ww w. ja va2 s . co m*/ miAdd.setTitle(getResources().getString(R.string.add_host)); } miEdit.setEnabled(targetIsValid); miDelete.setEnabled(targetIsValid); miEdit.setShowAsAction(targetIsValid ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER); miDelete.setShowAsAction(targetIsValid ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER); // hide replace menu item under the unfoldable menu miAdd.setShowAsAction(targetIsValid ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS); return super.onPrepareOptionsMenu(menu); }
From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service.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 www . j av a2s.c o m if (isShowOneKey) item.setVisible(true); else item.setVisible(false); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.koushikdutta.superuser.FragmentMain.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem mode = menu.add(Menu.NONE, Menu.NONE, 100, R.string.list_mode); mode.setTitle(pref.getBoolean("grid_mode", true) ? R.string.list_mode : R.string.grid_mode); mode.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mode.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//from w w w .j a va 2s. c om public boolean onMenuItemClick(MenuItem menuItem) { if (pref.edit().putBoolean("grid_mode", !pref.getBoolean("grid_mode", true)).commit()) getActivity().recreate(); return true; } }); if (!gridMode) return; MenuItem gridSize = menu.add(Menu.NONE, Menu.NONE, 101, R.string.grid_size); gridSize.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); gridSize.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { int sizePort = pref.getInt("grid_size_port", 3); int sizeLand = pref.getInt("grid_size_land", 4); final AlertDialog.Builder builder = new AlertDialog.Builder(context); View parent = LayoutInflater.from(context).inflate(R.layout.dialog_settings_grid_size, null); final AppCompatSeekBar seekPort = (AppCompatSeekBar) parent.findViewById(R.id.seek_port); seekPort.setProgress(sizePort - 3); final AppCompatSeekBar seekLand = (AppCompatSeekBar) parent.findViewById(R.id.seek_land); seekLand.setProgress(sizeLand - 3); builder.setView(parent); builder.setPositiveButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { SharedPreferences.Editor editor = pref.edit(); editor.putInt("grid_size_port", seekPort.getProgress() + 3); editor.putInt("grid_size_land", seekLand.getProgress() + 3).apply(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { int val = seekPort.getProgress() + 3; layoutManager.setSpanCount(val); callback.onGridSpanChanged(type, val); } else if (getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { int val = seekLand.getProgress() + 3; layoutManager.setSpanCount(val); callback.onGridSpanChanged(type, val); } } }); builder.show(); return true; } }); }
From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java
private void getMenu(Menu menu, int mode) { MenuItem mi = null; switch (mode) { case MODE_CALL: if (person.getTelephoneNumber() != null && !person.getTelephoneNumber().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_TEL, Menu.FIRST + MenuActionItem.MENU_TEL, person.getTelephoneNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }// w w w. ja v a 2 s . c o m if (person.getMobileNumber() != null && !person.getMobileNumber().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_MOBILE, Menu.FIRST + MenuActionItem.MENU_MOBILE, person.getMobileNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (person.getCompany() != null && person.getCompany().getTelephoneNumber() != null && !person.getCompany().getTelephoneNumber().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_TEL, Menu.FIRST + MenuActionItem.MENU_COMPANY_TEL, person.getCompany().getTelephoneNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } break; case MODE_SKYPE: mi = menu.add(Menu.NONE, MenuActionItem.MENU_CHAT, Menu.FIRST + MenuActionItem.MENU_CHAT, R.string.start_chat); mi.setIcon(R.drawable.ic_im); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, MenuActionItem.MENU_CALL, Menu.FIRST + MenuActionItem.MENU_CALL, R.string.start_call); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, MenuActionItem.MENU_VIDEOCALL, Menu.FIRST + MenuActionItem.MENU_VIDEOCALL, R.string.start_video_call); mi.setIcon(R.drawable.ic_videocall); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); break; case MODE_EMAIL: if (person.getEmail() != null && !person.getEmail().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_EMAIL, Menu.FIRST + MenuActionItem.MENU_EMAIL, person.getEmail()); mi.setIcon(R.drawable.ic_send_mail); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (person.getCompany() != null && person.getCompany().getEmail() != null && !person.getCompany().getEmail().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_EMAIL, Menu.FIRST + MenuActionItem.MENU_COMPANY_EMAIL, person.getCompany().getEmail()); mi.setIcon(R.drawable.ic_send_mail); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } break; default: break; } }
From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { toolsSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST, R.string.editor_tools);//from w w w . j av a2 s .c o m toolsSubMenu.setIcon(R.drawable.ic_edit); toolsSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // TOOLS MENU MenuItem mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PEN, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PEN, R.string.editor_pen); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TEXT, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_TEXT, R.string.editor_text); mi.setIcon(R.drawable.ic_text); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SELECTION, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SELECTION, R.string.editor_selection); mi.setIcon(R.drawable.ic_selection); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ERASER, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ERASER, R.string.editor_eraser); mi.setIcon(R.drawable.ic_eraser); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // TOOL SETTINGS MENU SubMenu toolsSettingSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS, R.string.editor_tools_settings); toolsSettingSubMenu.setIcon(R.drawable.ic_action_settings); toolsSettingSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_PEN, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_PEN, R.string.editor_pen); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_TEXT, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_TEXT, R.string.editor_text); mi.setIcon(R.drawable.ic_text); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_SELECTION, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_SELECTION, R.string.editor_selection); mi.setIcon(R.drawable.ic_selection); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_ERASER, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_ERASER, R.string.editor_eraser); mi.setIcon(R.drawable.ic_eraser); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // ADD MENU SubMenu addSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ADD, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ADD, R.string.editor_add_menu); addSubMenu.setIcon(R.drawable.ic_add); addSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // IMAGE mi = addSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ADD_IMAGE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ADD_IMAGE, R.string.editor_add_image); mi.setIcon(R.drawable.ic_add_image); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // PAGES SubMenu pagesMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE, R.string.editor_pages); pagesMenu.setIcon(R.drawable.ic_pages); pagesMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_MOVE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_MOVE, R.string.editor_pages_move); mi.setIcon(R.drawable.ic_pages); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_ADD, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_ADD, R.string.editor_pages_add); mi.setIcon(R.drawable.ic_add_page); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_DELETE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_DELETE, R.string.editor_pages_remove); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // EXTRA SETTINGS // SAVE mi = menu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SAVE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SAVE, R.string.editor_save); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); super.onCreateOptionsMenu(menu); return true; }
From source file:org.alfresco.mobile.android.application.fragments.user.UserProfileFragment.java
private void getMenu(Menu menu, int mode) { MenuItem mi = null; switch (mode) { case MODE_CALL: if (person.getTelephoneNumber() != null && !person.getTelephoneNumber().isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_user_phone, Menu.FIRST + 6, person.getTelephoneNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }//from w ww .j av a2s .c o m if (person.getMobileNumber() != null && !person.getMobileNumber().isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_user_mobile, Menu.FIRST + 7, person.getMobileNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (person.getCompany() != null && person.getCompany().getTelephoneNumber() != null && !person.getCompany().getTelephoneNumber().isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_user_company_phone, Menu.FIRST + 5, person.getCompany().getTelephoneNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } break; case MODE_SKYPE: mi = menu.add(Menu.NONE, R.id.menu_user_chat, Menu.FIRST, R.string.start_chat); mi.setIcon(R.drawable.ic_im); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, R.id.menu_user_call, Menu.FIRST + 1, R.string.start_call); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, R.id.menu_user_videocall, Menu.FIRST + 2, R.string.start_video_call); mi.setIcon(R.drawable.ic_videos); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); break; case MODE_EMAIL: if (person.getEmail() != null && !person.getEmail().isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_user_email, Menu.FIRST + 3, person.getEmail()); mi.setIcon(R.drawable.ic_send_mail); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (person.getCompany() != null && person.getCompany().getEmail() != null && !person.getCompany().getEmail().isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_user_company_email, Menu.FIRST + 4, person.getCompany().getEmail()); mi.setIcon(R.drawable.ic_send_mail); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } break; default: break; } }
From source file:net.ustyugov.jtalk.activity.XMLConsole.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.xml, menu);/*w ww . j a v a 2s .c om*/ MenuItem.OnActionExpandListener listener = new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { searchString = ""; updateList(); return true; } @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } }; SearchView searchView = new SearchView(this); searchView.setQueryHint(getString(android.R.string.search_go)); searchView.setSubmitButtonEnabled(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { return false; } @Override public boolean onQueryTextSubmit(String query) { searchString = query; updateList(); return true; } }); MenuItem item = menu.findItem(R.id.search); item.setActionView(searchView); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); item.setOnActionExpandListener(listener); return super.onCreateOptionsMenu(menu); }
From source file:com.guipenedo.pokeradar.activities.MapsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem settings = menu.add(0, 0, 0, R.string.settings).setIcon(R.drawable.cog); settings.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//from ww w . j av a 2s.c o m public boolean onMenuItemClick(MenuItem menuItem) { Intent i = new Intent(getBaseContext(), MainSettingsActivity.class); startActivity(i); return true; } }); MenuItem info = menu.add(0, 0, 0, R.string.about).setIcon(R.drawable.info_circle); info.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { Intent i = new Intent(getBaseContext(), AboutActivity.class); startActivity(i); return true; } }); info.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); settings.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); MenuItem logOut = menu.add(0, 0, 0, R.string.log_out).setIcon(R.drawable.sign_out); logOut.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { Utils.relog(MapsActivity.this); return true; } }); logOut.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; }