UMAR-MOBITSOLUTIONS UMAR-MOBITSOLUTIONS - 3 months ago 16
Android Question

How to implement master and child page like Activity in Android?

I want to place a common banner and menu on each Activity with footer too.

Can anyone guide me how can I implement master and child page like asp.net in Android???

Any help would be appreciated.

Answer

You could have each of your Activities extend a common base class which has a onCreateOptionsMenu method which inflates the menu from the same XML each time. Though as you can't have multiple inheritance, this may be tricky when you want to have plain activities and list activities, for example.

Another way would be to have a Util class where you have a method like setupMenu(Menu) which each of your Activities can call if you're doing some more complex menu setup.

In terms of the XML UI layout for each of your Activities, you can include a common banner by using the <include/> tag.