Skip to content Skip to sidebar Skip to footer

Optionmenu Does Not Show....

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // mEditor=(TextView)fin

Solution 1:

take a look link1 or link2. Or if don't want to inflate menu.xml, you can do this :

Try the following one, you don't need to inflate xml in this.

package com.menusample;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

publicclassMenuSampleActivityextendsActivity {
    /** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


    }


    @OverridepublicbooleanonCreateOptionsMenu(Menu menu) {

    //menu.add(int groupId,int itemId,int orderId, Charsequence title); 
        menu.add(0, 0, 0, "title1");
        menu.add(0, 1, 1, "title2");
        menu.add(0, 2,2, "title3");
        menu.add(0, 3, 3, "title4");

        returnsuper.onCreateOptionsMenu(menu);
    }
}

Solution 2:

The only difference that I can see in the code from my code is that in your XML file, the line

<menu xmlns:android="schemas.android.com/apk/res/android"; >

has a semi-colon at the end.

Mine does not, and the example from Android, at http://developer.android.com/guide/topics/ui/menus.html, does not have a semi-colon either.

The line of code should look like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android">

Post a Comment for "Optionmenu Does Not Show...."