选项​​菜单中没有出现的Andr​​oid [英] Option Menu does not appear in Android

查看:133
本文介绍了选项​​菜单中没有出现的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的code创建菜单:

I have this code to create the menu:

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

}


@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case MNU_PREV:
        animateTextViewsPrev();
        break;

    case MNU_NEXT:
        animateTextViewsNext();
        break;
    }

    return true;
}

和XML:

<?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
        <item android:id="@+id/prev_tip" android:title="@string/prevTip"></item>
        <item android:id="@+id/next_tip" android:title="@string/nextTip"></item>
    </menu>

在与Android 2.1智能手机的菜单是可见的,但在其他移动丝毫4.1.1是看不见的。
现在有人怎么解决呢?

In a smartphone with Android 2.1 the menu is visible but in other mobile whit 4.1.1 is invisible. Somebody now how to solve it?

推荐答案

什么是你的目标的Andr​​oid,好知道,在Android 4.0的他们拥有重新设计的菜单布局。

What is you target Android, good to know, in android 4.0 them has redesign the menu layout.

我觉得你是缺少 super.onCreateOptionsMenu(菜单); 呼叫 onCreateOptionsMenu

在我的code我了,

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

这篇关于选项​​菜单中没有出现的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆