I'm new to android and I'm trying to figure out if there is a best practice in menu handling.
Well, here is the thing:
I have created a menu.xml
file (wi开发者_StackOverflowthin res/menu
), Main.java
handle the menu action with a switch case
.
I'm wondering what is the best way to run appropriate task when an action is performed on a menu item:
- Use an intent and trigger the corresponding activity
- define everything (which could be a lot of code) within the case corresponding to this menu item.
...
startActivity(new Intent(getApplicationContext(),MyOtherActivity.class));
return;
it doesn't have to be more complicated than that.
精彩评论