开发者

Android, trigger Activity on menu action

开发者 https://www.devze.com 2022-12-18 04:36 出处:网络
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'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

精彩评论

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