Java Code Examples for android.view.MenuItem.setAlphabeticShortcut()

The following are Jave code examples for showing how to use setAlphabeticShortcut() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GitHub   File: ColorsActivity.java   Source Code and License Vote up 5 votes
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);

	MenuItem reset = menu.add(R.string.menu_colors_reset);
	reset.setAlphabeticShortcut('r');
	reset.setNumericShortcut('1');
	reset.setIcon(android.R.drawable.ic_menu_revert);
	reset.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		public boolean onMenuItemClick(MenuItem arg0) {
			// Reset each individual color to defaults.
			for (int i = 0; i < Colors.defaults.length; i++) {
				if (mColorList[i] != Colors.defaults[i]) {
					mHostDb.setGlobalColor(i, Colors.defaults[i]);
					mColorList[i] = Colors.defaults[i];
				}
			}
			mColorGrid.invalidateViews();

			// Reset the default FG/BG colors as well.
			mFgSpinner.setSelection(HostDatabase.DEFAULT_FG_COLOR);
			mBgSpinner.setSelection(HostDatabase.DEFAULT_BG_COLOR);
			mHostDb.setDefaultColorsForScheme(HostDatabase.DEFAULT_COLOR_SCHEME,
					HostDatabase.DEFAULT_FG_COLOR, HostDatabase.DEFAULT_BG_COLOR);

			return true;
		}
	});

	return true;
}