List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:com.example.android.supportv7.app.ActionBarActionMode.java
private void startActionMode() { startSupportActionMode(new ActionMode.Callback() { @Override/*from w w w . ja va2 s. co m*/ public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.getMenuInflater().inflate(R.menu.actions, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { Toast.makeText(ActionBarActionMode.this, "Action Mode item clicked:" + item.getTitle(), Toast.LENGTH_SHORT).show(); return true; } @Override public void onDestroyActionMode(ActionMode mode) { } }); }
From source file:com.example.android.supportv7.widget.PopupMenuActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.popup_menu_activity); mDateFormat = new SimpleDateFormat("HH:mm:ss.SSS"); final ViewGroup container = findViewById(R.id.container); mLog = (TextView) container.findViewById(R.id.log); final SwitchCompat elevationToggle = (SwitchCompat) container.findViewById(R.id.elevation_toggle); final Button button = (Button) container.findViewById(R.id.test_button); button.setOnClickListener(new View.OnClickListener() { @Override/* w w w. java2s .c om*/ public void onClick(View v) { // Do we need to use a custom style that removes elevation? boolean useDefaultElevation = elevationToggle.isChecked(); PopupMenu popupMenu = null; if (useDefaultElevation) { popupMenu = new PopupMenu(container.getContext(), button); } else { popupMenu = new PopupMenu(container.getContext(), button, Gravity.NO_GRAVITY, 0, R.style.CustomPopupNoElevation); } final MenuInflater menuInflater = popupMenu.getMenuInflater(); menuInflater.inflate(R.menu.popup_menu, popupMenu.getMenu()); final MenuItem editItem = popupMenu.getMenu().findItem(R.id.action_edit); MenuItemCompat.setContentDescription(editItem, getString(R.string.popup_menu_edit_description)); MenuItemCompat.setTooltipText(editItem, getString(R.string.popup_menu_edit_tooltip)); // Register a listener to be notified when a menu item in our popup menu has // been clicked. popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { addToLog("Item '" + item.getTitle() + "' clicked"); return true; } }); // Register a listener to be notified when our popup menu is dismissed. popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { addToLog("Popup menu dismissed"); } }); // Show the popup menu popupMenu.show(); } }); }
From source file:ie.tcd.scss.dsg.particpatory.SampleListFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Menu menu = newMenuInstance(getActivity()); if (menu != null) { new MenuInflater(getActivity()).inflate(R.menu.sliding_menu, menu); MenuListAdapter adapter = new MenuListAdapter(getActivity()); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); adapter.add(new SampleItem(item.getTitle().toString(), item.getIcon())); }//from w ww . ja va 2s . c om setListAdapter(adapter); } else { TextView emptyText = new TextView(getActivity()); emptyText.setText("No Menu"); getListView().setEmptyView(emptyText); } ListView listView = new ListView(getActivity()); listView.setId(android.R.id.list); return listView; }
From source file:uk.ac.horizon.ug.exploding.client.logging.ActivityLogger.java
public void logOnContextItemSelected(MenuItem item) { log("onContextItemSelected", "item", item.getTitle().toString()); }
From source file:uk.ac.horizon.ug.exploding.client.logging.ActivityLogger.java
public void logOnOptionsItemSelected(MenuItem item) { log("onOptionsItemSelected", "item", item.getTitle().toString()); }
From source file:com.destin.moeviewer.posts.PostsActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. setTitle(item.getTitle()); switch (item.getItemId()) { case R.id.nav_yande: mPostsPresenter.setProvider(YandeRepository.getInstance()); break;//from w w w . j a v a 2 s .c om case R.id.nav_konachan: mPostsPresenter.setProvider(KonachanRepository.getInstance()); break; case R.id.nav_donmai: mPostsPresenter.setProvider(DonmaiRepository.getInstance()); break; case R.id.nav_safebooru: mPostsPresenter.setProvider(SafebooruRepository.getInstance()); break; case R.id.nav_shuushuu: mPostsPresenter.setProvider(ShuushuuRepository.getInstance()); break; case R.id.nav_zerochan: mPostsPresenter.setProvider(ZerochanRepository.getInstance()); break; case R.id.nav_monitokyo: mPostsPresenter.setProvider(MinitokyoRepository.getInstance()); break; default: break; } mDrawerLayout.closeDrawer(GravityCompat.START); return true; }
From source file:me.spadival.podmode.MainActivity.java
public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(); if (item.getTitle().equals(getString(R.string.menu_notices))) intent.setClass(MainActivity.this, NoticesActivity.class); else//from ww w . j a v a 2 s . c o m intent.setClass(MainActivity.this, SettingsActivity.class); startActivityForResult(intent, 0); return true; }
From source file:net.kjmaster.cookiemom.editor.EditDataActivity.java
@Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { if (menuItem.getTitle().equals(getString(R.string.cancel))) { cookieTransactionsList.clear();// ww w . j av a 2 s .c om actionMode.finish(); afterViews(); return true; } return true; }
From source file:com.chale22.ico01.fragments.FragmentContact.java
@Override public void onMenuItemClick(Card card, MenuItem item) { Toast.makeText(getActivity(), card.getTitle() + ": " + item.getTitle(), Toast.LENGTH_SHORT).show(); }
From source file:com.fusionx.lightirc.ui.ChannelFragment.java
@Override public boolean onMenuItemClick(final MenuItem menuItem) { final String nick = menuItem.getTitle().toString(); changeLastWord(nick);//from ww w. j av a 2 s . c om isPopupShown = false; return true; }