The Android Action Bar menu does not appear when the target version of sdk is greater than 10. Why?

I have a wide application menu that will not always be displayed. In particular, my problem is that when I set the target version of sdk to 16 for devices without a hardware menu button. 3 dots (action bar?), Which should appear, do not work.

I have the following manifest entries

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

In the avd emulator without hardware buttons, I see 3 dots for the action bar menu

But if I set the goal to 16

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

Action bar not showing

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

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

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

The manifest item to set the theme

 <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"> 

I have to wonder if I need to configure resource folders with styles for ALL sdk versions?

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

UPDATE I am now using ActionBarSherlock without problems

+5
android android-actionbar android-menu
Sep 21
source share
1 answer

See the link @ Mr.S, Android does not have a MENU button , for more information about the problem.

But to answer your questions:

I have to wonder if I need to configure resource folders with styles for ALL sdk versions?

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

  • values.xml
  • values-v11.xml
  • values-v16.xml

In the following example, Android OS levels will use:

  • API 4: values.xml
  • API 10: values.xml
  • API 11: values-v11.xml
  • API 13: values-v11.xml
  • API 16: values-v16.xml

And so on.

I do not understand what the correct approach should be to be able to set android: targetSdkVersion = "16" And have an action bar (3 points)

If the action is full-screen, any API level (min or goal) above 10 will lead to the disappearance of points. The only way is to write your own menu system or use a pad library, such as ActionBarSherlock .

If the activity usually has a title bar, but you want to set the API level above 10, then you must set Holo.Theme in the code for the activity. See Holo Everywhere and the Android theme, full screen mode and action bar for how to do this.

UPDATE: Please note that new Android manuals do not require a hardware menu button. And this hack only works for devices that use soft buttons (for example, Nexus 7). For devices that do not offer any (like, for example, many HTC devices), then the user will not be able to get to the menu - even with this hack. It is highly recommended that you switch to the action bar concept.

+5
Nov 12 '12 at 4:25
source share



All Articles