Skip to content

Commit 2db7e7b

Browse files
committed
Implemented Quit Menu item
1 parent e79d0b2 commit 2db7e7b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/com/example/menuoptions/MainActivity.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,23 @@ public boolean onCreateOptionsMenu(Menu menu) {
2525
//Adding Menu Items Programatically
2626
menu.add(Menu.NONE, ITEM_COLORS_ID, Menu.NONE, R.string.colors);
2727
menu.add(Menu.NONE, ITEM_OPTIONS_ID, Menu.NONE, R.string.options);
28-
menu.add(Menu.NONE, ITEM_QUIT_ID, Menu.NONE, R.string.quit);
28+
menu.add(Menu.NONE, ITEM_QUIT_ID, Menu.NONE, R.string.quit); //Is Quit Menu, a good practice for Android app??
2929

3030
return true;
3131
}
3232

3333
@Override
3434
public boolean onOptionsItemSelected(MenuItem item) {
3535
int id = item.getItemId();
36-
if (id == R.id.action_settings) {
37-
return true;
36+
//if (id == R.id.action_settings) { return true; }
37+
if (id == ITEM_COLORS_ID) {
38+
//
39+
} else if (id == ITEM_OPTIONS_ID ) {
40+
//
41+
} else if (id == ITEM_QUIT_ID){
42+
finish();
3843
}
39-
return super.onOptionsItemSelected(item);
44+
// return super.onOptionsItemSelected(item);
45+
return true;
4046
}
4147
}

0 commit comments

Comments
 (0)