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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -