开发者

Android, trigger Activity on menu action

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜