java - Android Refactor Menu Class -


I have a menu class for the Android application and I think I can refract it because I have about 4 The bar is the same method, please see below:

  Public abstract class activity enhances SherlockActivity {Create a bundle saved instenestate {super.onCreate (savedInstanceState); ActionBar AB = Letarslock (). GetActionBar (); Sherlock Hiller Setup section (now, this); } @ Override Public Boolean On Crate Option Menus (Menu Menu) {Return Create menu (this, menus); } Public Stability Boolean Maneu (Sherlock Activity Achievement, Menu Menu) {MenuInflater inflater = (ShareLock Activity) Aactive) .getSupportMenuInflater (); Inflater.inflate (R. menu.main_menu, menu); Intent I = new intent ((reference) is an activity, directional activity class); I.putext ("flag", "first instructions"); Menu.findItem (R.id.hearing_test) .setIntent (i); Menu.findItem (R.id.learn) .setIntent (new intent ((reference) an activity, LearnActivity.class)); Menu.findItem (R.id.share) .setIntent (New Intention ((Referred to an activity, ShareActivity.class)); Menu.findItem (R.id.locate) .setIntent (new intent (a reference to an activity, MapActivity.class)); Menu.findItem (R.id.saved) .setIntent (new intent (a reference to an activation, savedResultsActivity.class)); Back true; } Build public static building menu (Sherlock Holistic ActiveActivity, menu menu) {MenuInflater inflater = aActivity.getSupportMenuInflater (); Inflater.inflate (R. menu.main_menu, menu); Intent I = new intent ((reference) is an activity, directional activity class); I.putext ("flag", "first instructions"); Menu.findItem (R.id.hearing_test) .setIntent (i); Menu.findItem (R.id.learn) .setIntent (new intent (aactivity, LearnActivity.class)); Menu.findItem (Rid.share) .setIntent (new intent (aactivity, ShareActivity.class)); Menu.findItem (R.id.locate) .setIntent (new intent (aActivity, MapActivity.class)); Menu.findItem (R.id.saved) .setIntent (new effect (aActivity, SavedResultsActivity.class)); Back true; } Create public static boolean menu (Sherlock fragment active activation, menu menu) {MenuInflater inflater = aActivity.getSupportMenuInflater (); Inflater.inflate (R. menu.main_menu, menu); Intent I = new intent ((reference) is an activity, directional activity class); I.putext ("flag", "first instructions"); Menu.findItem (R.id.hearing_test) .setIntent (i); Menu.findItem (R.id.learn) .setIntent (new intent (aactivity, LearnActivity.class)); Menu.findItem (Rid.share) .setIntent (new intent (aactivity, ShareActivity.class)); Menu.findItem (R.id.locate) .setIntent (new intent (aActivity, MapActivity.class)); Menu.findItem (R.id.saved) .setIntent (new effect (aActivity, SavedResultsActivity.class)); Back true; } Build public static building menu (Sherlock fragment, activity menu, menu menu) {MenuInflater inflater = aActivity.getSherlockActivity (). GetSupportMenuInflater (); Inflater.inflate (R. menu.main_menu, menu); Intent I = new intent ((reference) aActivity.getSherlockActivity (), command disabled.clus;); I.putext ("flag", "first instructions"); Menu.findItem (R.id.hearing_test) .setIntent (i); Menu.findItem (R.id.learn) .setIntent (new intent (aActivity.getSherlockActivity (), LearnActivity.class)); Menu.findItem (Rid.share) .setIntent (new intent (aActivity.getSherlockActivity (), ShareActivity.class)); Menu.findItem (R.id.locate) .setIntent (new intent (aActivity.getSherlockActivity (), MapActivity.class)); Menu.findItem (R.id.saved) .setIntent (new intent (aActivity.getSherlockActivity (), SavedResultsActivity.class)); Back true; }}  

I want to change this so I do not have only one method. To do this, I think that I pass through a generic object, but I do not really know Is that what's going to be! Do I need to change the methods in a dynamic one instead of static?

Any help on this will be appreciated. Thank you very much

To create whatever you need in the body, you should only context < / Code> requires all of your methods.

Remove the same comedy in a method that takes context as the argument, so that you can call this method as often as you need it.

In this case, this error is a free code, because you have to handle all the things about the AVCLASS with the user and you do not know what you have in your system Have done


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -