List of usage examples for android.view MenuItem SHOW_AS_ACTION_ALWAYS
int SHOW_AS_ACTION_ALWAYS
To view the source code for android.view MenuItem SHOW_AS_ACTION_ALWAYS.
Click Source Link
From source file:com.money.manager.ex.search.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); UIHelper ui = new UIHelper(this); // Add Search icon. getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem item = menu.findItem(R.id.searchMenuItem); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); item.setIcon(ui.getIcon(GoogleMaterial.Icon.gmd_search)); // show this menu item last return true;//from w w w.ja va 2 s . co m }
From source file:com.duy.pascal.ui.file.FileExplorerAction.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste); pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); pasteMenu.setEnabled(mFileClipboard.canPaste()); mRenameMenu = menu.add(0, R.id.rename, 0, R.string.rename); mRenameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mShareMenu = menu.add(0, R.id.share, 0, R.string.share); mShareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mShareActionProvider = new ShareActionProvider(mContext); mShareActionProvider.setOnShareTargetSelectedListener(this); MenuItemCompat.setActionProvider(mShareMenu, mShareActionProvider); menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); return true;// w w w. j a v a2s . com }
From source file:com.numenta.taurus.TaurusBaseActivity.java
@SuppressLint("AlwaysShowAction") private void updateRefresh() { if (_refresh != null) { if (TaurusApplication.isRefreshing()) { _refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); _refresh.setActionView(_refreshView); // Calculate the interval since last connection to the server final SharedPreferences pref = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); final long now = System.currentTimeMillis(); final long lastConnected = pref.getLong(PREF_LAST_CONNECTED_TIME, now); final long interval = now - lastConnected; // Notify the user if the last time we connected was more than one hour ago if (interval > DataUtils.MILLIS_PER_HOUR) { final long hour = interval / DataUtils.MILLIS_PER_HOUR; final long minutes = (interval % DataUtils.MILLIS_PER_HOUR) / DataUtils.MILLIS_PER_MINUTE; if (hour > 0) { String title; // Format message: "X hours ago" or "X hours and Y minutes ago" if (minutes > 0) { title = getApplicationContext().getString(R.string.loading_metrics_title_hours_minutes, hour, minutes); } else { title = getApplicationContext().getString(R.string.loading_metrics_title_hours, hour); }// ww w . j av a 2 s . c om Toast.makeText(this, title, Toast.LENGTH_LONG).show(); } } } else { // Check if we have an error message String refreshError = TaurusApplication.getLastError(); if (refreshError == null) { _refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); // Restore refresh icon _refresh.setIcon(R.drawable.ic_action_refresh); } else { _refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // Show error icon _refresh.setIcon(R.drawable.ic_action_connection_error); } _refresh.setActionView(null); } } }
From source file:de.appetites.android.menuItemSearchAction.MenuItemSearchAction.java
private void createMenuItem(Menu menu, Drawable drawable, final LinearLayout list) { ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setLayoutParams(layoutParams);//from w ww . j a v a2s . c o m setHint(R.string.menu_item_search_action_hint); searchItem = menu.add(R.string.menu_item_search_action_menu_text).setIcon(drawable); searchItem.setActionView(this).setTitle("Search"); searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { // open keyboard list.setVisibility(View.VISIBLE); MenuItemSearchAction.this.setText(""); MenuItemSearchAction.this.requestFocus(); MenuItemSearchAction.this.postDelayed(new Runnable() { @Override public void run() { InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } }, 200); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { // close keyboard list.setVisibility(View.GONE); InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(MenuItemSearchAction.this.getWindowToken(), 0); return true; } }); setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { // perform Search searchPerformListener.performSearch(MenuItemSearchAction.this.getText().toString()); searchItem.collapseActionView(); return true; } return false; } }); }
From source file:com.android.settings.aicp.AicpSettings.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.add(0, MENU_HELP, 0, "Help Us, Help You!!").setIcon(R.drawable.ic_action_help) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); }
From source file:th.in.ffc.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem whatnew = menu.add(Menu.NONE, R.layout.whatnew_dialog, Menu.NONE, "what new"); whatnew.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); SharedPreferences sp = getSharedPreferences(FamilyFolderCollector.TAG, MODE_PRIVATE); int prev = sp.getInt(FamilyFolderCollector.PREF_VERSION, 0); int now = getResources().getInteger(R.integer.version_code); whatnew.setIcon((now > prev) ? R.drawable.ic_action_star : R.drawable.ic_action_start_dark); return super.onCreateOptionsMenu(menu); }
From source file:com.shafiq.mytwittle.view.TutorialActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); int currentItem = mViewPager.getCurrentItem(); if (currentItem != PAGE_WELCOME) { menu.add(getString(R.string.action_previous)) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/* w w w . ja va2s . c o m*/ public boolean onMenuItemClick(MenuItem item) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1); return true; } }).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } if (currentItem != PAGE_THANKS) { menu.add(getString(R.string.action_next)) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1); return true; } }).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } return true; }
From source file:com.evvsoft.treeview.demo.DemoActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { SubMenu sub = menu.addSubMenu("Theme"); sub.add(0, R.style.Theme_TreeView_Light, 0, "Light"); sub.add(0, R.style.Theme_TreeView_Dark, 0, "Dark"); sub.add(0, R.drawable.expander_custom_group_holo_light, 0, "Custom group indicator"); sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true;// w ww. j ava2s . c o m }
From source file:com.examples.abelanav2.ui.PicturesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem refreshMenu = menu.add(R.string.action_refresh); refreshMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); refreshMenu.setOnMenuItemClickListener(this); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.support.android.designlibdemo.data.maps.MapActivity.java
/**********************************************************************************************/ @Override// ww w .java2 s . c o m public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, 0, 0, "LISTO").setIcon(R.drawable.ic_check_white_24dp) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return true; }