Sayem Siam
Sayem Siam

Reputation: 199

OptionMenu does not show anything

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // mEditor=(TextView)findViewById(R.id.text);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    super.onCreateOptionsMenu(menu);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);

    Log.d("sayem", "onCreateOptionMEnu");

    return true;

}

And this is my menu.xml file path res/menu/menu.xml

<item
    android:id="@+id/settings"
    android:alphabeticShortcut="@string/settings_shortcut"
    android:icon="@drawable/violet"
    android:title="@string/settings_label"
    android:visible="true"/>

It does not show any kind of menu as expected.

Upvotes: 0

Views: 132

Answers (1)

Jack
Jack

Reputation: 9252

If you look at the example here, the menu.xml file (or game_menu.xml file) has an outer tag called <menu>. I don't see that in yours.

Example:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/new_game"
          android:icon="@drawable/ic_new_game"
          android:title="@string/new_game" />
    <item android:id="@+id/help"
          android:icon="@drawable/ic_help"
          android:title="@string/help" />
</menu>

Either you have not posted your full menu.xml, or it isn't formed as it should be.

Upvotes: 1

Related Questions