Created
October 24, 2011 13:27
-
-
Save sakurabird/1309022 to your computer and use it in GitHub Desktop.
Untouchable メニュー
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//inflaterを使ってxmlリソースファイルを読み込んでメニューを作成する。 | |
@Override | |
publicboolean onCreateOptionsMenu( Menu menu ) { | |
super.onCreateOptionsMenu( menu ); | |
MenuInflater inflater = getMenuInflater(); | |
//インフレートしています | |
inflater.inflate( R.menu.option_menu, menu ); | |
returntrue; | |
} | |
//メニューで何か選択された場合の処理 | |
@Override | |
publicboolean onOptionsItemSelected( MenuItem item ) { | |
super.onOptionsItemSelected( item ); | |
// 通常メッセージをセットしておく | |
tv_sensor_message.setText( R.string.message_waiting ); | |
//リソースのIDを使って、どのメニューが選択されたかを判定している。 | |
switch ( item.getItemId() ) { | |
case R.id.menu_setting: | |
Intent settingIntent = new Intent( this, SettingActivity.class ); | |
startActivity( settingIntent ); | |
break; | |
case R.id.menu_help: | |
Intent intent = new Intent( mContext, HelpActivity.class ); | |
intent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); | |
startActivity( intent ); | |
break; | |
case R.id.menu_about: | |
showAboutDialog(); | |
break; | |
case R.id.menu_sensor_sensitivity: | |
Intent sensorIntent = new Intent( mContext, SensorSensitivityActivity.class ); | |
sensorIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); | |
startActivity( sensorIntent ); | |
break; | |
} | |
return super.onOptionsItemSelected( item ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment