java - How do you write an extra class for often used code and call it from everywhere? -


in little app users can have @ 'more information' or send me feedback when click on the menu button (of device) @ every xml file of app.

this code (when click on menu button):

@override public boolean oncreateoptionsmenu(menu menu) {     getmenuinflater().inflate(r.menu.menu, menu);     return super.oncreateoptionsmenu(menu); } @override public boolean onoptionsitemselected(menuitem item) {     switch (item.getitemid()) {          case r.id.impressum:                     startactivity(new intent (this, moreinformation.class));          break;               case r.id.feedback:         /*         *         */         break;         }                return super.onoptionsitemselected(item); } 

now put code java classes. works i'd create class (let's call ismenubuttonpressed.class) contains code above , i'd remove code above other java classes , call ismenubuttonpressed.class (in these java classes when menu button pressed). how can that? how pass information on menu button pressed? how receive in ismenubuttonpressed.class?

thanks!

how write class used code , call everywhere?

by letting custom class define actual behaviour menu. read asynchronous programming best practices answer more information regarding subject.


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -