0

为 ZTE Optik 平板电脑开发,该平板电脑底部有用于返回、主页等的浮动按钮。除非应用程序特别要求,否则菜单按钮不会出现(显然)。当我在平板电脑上打开 MyFitnessPal 时,会出现菜单按钮。但是,将选项菜单添加到我的应用程序时,菜单按钮永远不会出现。OnCreateOptionsMenu 永远不会被调用(或者至少断点没有被捕获)。我试图将菜单放在 TabbedActivity 本身以及 Activity 上。

主菜单.xml

<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+id/sendLog"
     android:title="Send Log"></item>
</menu>

主菜单.cs

    public override bool OnCreateOptionsMenu(IMenu menu)
    {
        MenuInflater menuInflater = MenuInflater;
        menuInflater.Inflate(Resource.Menu.MainMenu, menu);
        return true;
    }

    public override bool OnOptionsItemSelected(IMenuItem item)
    {
        switch (item.ItemId)
        {
            case Resource.Id.sendLog:
                var query = new SQLite("Select * From Log", true);
                SqliteDataReader dr = query.dr;
                List<logInfo> logs = new List<logInfo>();
                while (dr.Read())
                {
                    logInfo log = new logInfo
                    {
                        DateTime = dr["DateTime"].ToString(),
                        Call = dr["Call"].ToString(),
                        Activity = dr["Activity"].ToString(),
                        Message = dr["Message"].ToString()
                    };
                    logs.Add(log);
                }

                InventoryApp inst = new InventoryApp();
                inst.sendLog(logs.ToArray());
                return true;
            default:
                return base.OnOptionsItemSelected(item);
        }
    }
4

1 回答 1

0

The issue seemed to be that my Minimum Android Version was set to API Level 12. When I peeled it back to 10, the menu appeared. Not so sure why this was considered such a terrible question by one nonconstructive member?

于 2012-04-13T12:39:37.890 回答