@Override public boolean onOptionsItemSelected(MenuItem item) { Helpers.removeCurItem(item, Menu.FIRST + 1, (ViewPager) getView().getParent()); switch (item.getItemId()) { case R.id.app_settings: Intent intent = new Intent(context, PCSettings.class); startActivity(intent); break; } return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.set_menu_save: save(); return true; case R.id.set_menu_return: Toast.makeText(getApplicationContext(), "操作无效。", Toast.LENGTH_SHORT).show(); return true; } return (super.onOptionsItemSelected(item)); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.tablist: Helpers.getTabList( getString(R.string.menu_tab), (ViewPager) getView().getParent(), getActivity()); break; case R.id.app_settings: Intent intent = new Intent(context, PCSettings.class); startActivity(intent); break; } return true; }
// code which handles the action for each menu item public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settings: { Intent preferences_intent = new Intent(); preferences_intent.setComponent( new ComponentName(download_photos.this, preferences.class)); preferences_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(preferences_intent); return true; } case R.id.logout: { try { download_photos.this.facebook.logout(getApplicationContext()); } catch (IOException e) { e.printStackTrace(); } mPrefs = getSharedPreferences("COMMON", MODE_PRIVATE); SharedPreferences.Editor editor = mPrefs.edit(); editor.putString("access_token", null); editor.putLong("access_expires", 0); editor.putBoolean("logout", true); editor.commit(); finish(); return true; } case R.id.about: { // shows our customized about dialog AboutDialog about = new AboutDialog(this); about.show(); return true; } // lets deal with default case default: return super.onOptionsItemSelected(item); } }