不显示Android的动作栏菜单时,目标SDK版本是大于10,为什么? [英] Android Action Bar menu not showing when target sdk version is greater than 10. Why?

查看:178
本文介绍了不显示Android的动作栏菜单时,目标SDK版本是大于10,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用广泛的菜单,不会总是显示。具体来说特别是我的问题是,当我设定的目标SDK版本为16,没有硬件菜单按钮,设备的3个点(动作吧?)应该出现的ACTUA \ LLY没有。

I have an application wide menu that won't always show. Specifically specifically my issue is that when I set the target sdk version to 16 for devices with no hardware menu button The 3 dots (Action bar?) that should appear actua\lly don't.

我有以下的清单项目

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10" />

在一个AVD模拟器,没有硬件按钮我看到了3点的动作栏菜单

In an avd emulator with no hardware buttons I see the 3 dots for the action bar menu

但是,如果我设定的目标为16

But if I set the target to 16

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />

没有操作栏出现

我的风格在不同的资源文件夹设置 - 价值观,价值观,V11和值-V14

I have styles set in various resource folders - values, values-v11 and values-v14

和特别是在价值观V14我有,指出

and in particular in values-v14 I have a styles.xml file that states

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />

该清单项来设置主题为

The manifest entry to set the theme is

<application android:label="@string/app_name"
android:name="uk.co.pjadult.mobile.adult_reader_lib.BookLib"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">

我在想,如果我需要建立资源文件夹与风格ALL SDK版本?

I am left wondering if I need to set up resource folders with styles for ALL sdk versions?

我很茫然,什么正确的做法应该是为了能够设置的android:targetSdkVersion =16,并有操作杆(3点)菜单出现。

I am at a loss as to what the correct approach should be in order to be able to set android:targetSdkVersion="16" AND have the action bar (3 dots) menu appear

更新的我现在用ActionBarSherlock没有问题

UPDATE I am now using ActionBarSherlock with no issues

推荐答案

请参阅链接@ Mr.S提供的 Android的丢失的菜单按钮,对于一些更多的问题。

See the link @Mr.S provided, Android missing MENU button, for some more about the issue.

但是,为了回答你的问题:

But to answer your questions:

我在想,如果我需要建立与样式资源文件夹   对于所有的SDK版本?

I am left wondering if I need to set up resource folders with styles for ALL sdk versions?

没有。它会采取的最高可用的API。例如,如果您有:

No. It will take the highest available API. For example, if you have:

  • values​​.xml
  • 价值观v11.xml
  • 价值观v16.xml
  • values.xml
  • values-v11.xml
  • values-v16.xml

下面的例子Android操作系统的API级别将使用:

The following example Android OS API levels would use:

  • API 4: values​​.xml
  • API 10: values​​.xml
  • API 11:价值观v11.xml
  • API 13:价值观v11.xml
  • API 16:价值观v16.xml
  • API 4: values.xml
  • API 10: values.xml
  • API 11: values-v11.xml
  • API 13: values-v11.xml
  • API 16: values-v16.xml

等等。

我很茫然,什么正确的做法应该是,以   可以设置的android:targetSdkVersion =16,并有操作栏   (3点)菜单出现。

I am at a loss as to what the correct approach should be in order to be able to set android:targetSdkVersion="16" AND have the action bar (3 dots) menu appear

如果该活动是全屏,任何API级别(分或目标)10以上会导致点消失。解决这个问题的唯一方法是写自己的菜单系统,或使用如 ActionBarSherlock

If the activity is full screen, any API level (min or target) above 10 will cause the dots to disappear. The only way around this is to write your own menu system, or use a shim library like ActionBarSherlock.

如果该活动通常有一个标题栏,但你要设置超过10 API级别,那么您必须设置在$ Holo.Theme C $下的活性。看到这个全息到处的博客文章的 Android的主题,全屏和操作栏了解如何做到这一点

If the activity normally has a title bar, but you want to set the API level above 10, then you must set the Holo.Theme in code for the activity. See this Holo Everywhere blog post and Android theme, fullscreen and the action bar for how to do that.

更新:需要注意的是较新的Andr​​oid的硬件原则不需要硬件菜单按钮。而这种只适合于使用软按钮(类似的Nexus 7)设备。对于既不提供设备(例如像许多HTC设备),那么就没有办法为用户到达菜单即使有这样的黑客攻击。它的的建议切换到动作栏中概念。

UPDATE: Note that newer Android hardware guidelines do not require a hardware menu button. And this hack only works for devices that use soft buttons (like the Nexus 7). For devices that offer neither (like many HTC devices for example), then there will be no way for the user to get to the menu—even with this hack. It is highly recommended to switch to the action bar concept.

这篇关于不显示Android的动作栏菜单时,目标SDK版本是大于10,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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