3

I am creating an option menu. it has three option HOME, EMAIL, VISIT. All three options coming at the same row. i have to show HOME option above and rest two below to Home Option(according to attached Screen Shot).

Any Ideas?? Thanks.

enter image description here

Here is my XML file.

<menu android:id="@+id/new_game"
          android:icon="@drawable/red_no_bg"
          android:title="Home" />
    <item android:id="@+id/email"
          android:icon="@drawable/red_no_bg"
          android:title="Email" />
    <item android:id="@+id/help"
          android:icon="@drawable/red_no_bg"
          android:title="Visit Microsite" />
</menu>

Here is my code.

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.layout.overview_menu, menu);
        return true;
    }

Using the above code i am getting the all option in Same line.

1 Answer 1

2

You can Create in two ways

1.Statically.

2.Dynamically.

Am explaining the easiest method of adding menus.

Step 1: Create a new Android Application.

Step 2: After onCreate() method write onCreateOptionMenu();

Step 3: In onCreateOptionMenu() Write these lines

menu.add(11, 21, 1, "Gowtham").setIcon(R.drawable.ic_launcher);

Here "Gowtham" is title of your menu item You can Home&Email use instead of "Gowtham".

Ans use Any images Instead of ic.launcher

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.