开发者

OptionsMenu not displayed in activity?

I try to add an optionsMenu to my activity. I use the code from the android.developer guide :

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/new_game"
          and开发者_运维知识库roid: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>

and

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

I use the same code in two different activities, but only in one of them the optionsmenu is displayed... posting the whole activity code wouldnt make sense, so please comment if special code segments are helpful. I hope anyone can help me! THX

EDIT: I already found the problem : I overrode onKeyDown(..) and returned true at the end, so other key-related events have not been called...


I found this issue once and I got rid off by not using the string resource but placing menu name directly in title....Check if it works for you too or not....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜