【问题标题】:Wrong View Option Menu错误的视图选项菜单
【发布时间】:2013-12-04 22:48:52
【问题描述】:

我按照这个链接Here在Android项目中创建选项菜单的步骤@

但是在将它应用到我的项目而不是选项菜单垂直出现(4 行)之后,它出现了水平(4 个项目除以 2 行) 这里的问题可能是我的代码

@Override
        public boolean onOptionsItemSelected(MenuItem item)
        {
              switch (item.getItemId()) {
              case R.id.Settings:
                        // write code to execute when clicked on this option
                  Intent nextScreen3 = new Intent(getApplicationContext(), FirstSSettings.class);
                    startActivity(nextScreen3);
                         return true;   

              case R.id.Verify:
                         // write code to execute when clicked on this option
                        Intent nextScreen4 = new Intent(getApplicationContext(), Verify.class);
                        startActivity(nextScreen4);
                         return true;

               case R.id.callInfo:
                //   startActivity(new Intent().setClass(MainActivity.this, LoginActivity.class).setData(getIntent().getData()));                        // write code to execute when clicked on this option
                                              return true;

              case R.id.email:
                                             // write code to execute when clicked on this option
                                               return true;

                default:
                                    return super.onOptionsItemSelected(item);
          }
      }

【问题讨论】:

  • 你在哪个版本的 android 上测试这个?看起来该教程是在 4.0+ 手机上的,如果您使用的是 2.x 版本,它将看起来像您描述的那样。
  • 4.3版还有其他可能的问题吗?

标签: android list view optionmenu


【解决方案1】:

在您的 AndroidManifest.xml 中检查您所针对的 android 版本

它必须等于或高于 Honeycomb 的 API 版本 (11)。理想情况下,您将定位到最新版本的 Android(KitKat 为 19)。

查看清单中的

<uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

并确保 targetSdkVersion 至少为 11。

【讨论】:

    猜你喜欢
    • 2012-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-03
    相关资源
    最近更新 更多