Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 567
UMAR-MOBITSOLUTIONS Avatar asked Jan 28 '10 08:01

UMAR-MOBITSOLUTIONS


People also ask

How to create an Activity in Android?

To create the second activity, follow these steps: In the Project window, right-click the app folder and select New > Activity > Empty Activity. In the Configure Activity window, enter "DisplayMessageActivity" for Activity Name. Leave all other properties set to their defaults and click Finish.

What is MainActivity java in Android?

The main activity code is a Java file MainActivity.java. This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application. Following is the default code generated by the application wizard for Hello World!

What is MainActivity?

Typically, one activity in an app is specified as the main activity, which is the first screen to appear when the user launches the app. Each activity can then start another activity in order to perform different actions.

Can Android application have activity without layout?

The answer is yes it's possible. Activities don't have to have a UI. It's mentioned in the documentation, e.g.: An activity is a single, focused thing that the user can do.


1 Answers

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.

like image 164
Christopher Orr Avatar answered Oct 04 '22 12:10

Christopher Orr