5

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.

I have the following manifest entries

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

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

But if I set the target to 16

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

No action bar appears

I have styles set in various resource folders - values, values-v11 and values-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">

I am left wondering if I need to set up 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 have the action bar (3 dots) menu appear

UPDATE I am now using ActionBarSherlock with no issues

jamesc
  • 12,423
  • 15
  • 74
  • 113
  • http://developer.android.com/guide/topics/ui/actionbar.html – Rajesh Rajaram Sep 21 '12 at 13:06
  • @RajeshRajaram That doesn't answer my question. Thanks anyway – jamesc Sep 21 '12 at 13:08
  • Action bars are used as a replacement in Honeycomb or higher as they say in android official site; so thats why you're not getting it maybe – Rajesh Rajaram Sep 21 '12 at 13:17
  • 2
    I got the same issue. I think this [link](http://techblog.rokoder.com/android-missing-menu-button/) descibe this problem well. – Mr.S Sep 21 '12 at 13:16
  • Hello, could you please explain how you fixed the issue with using Android-SherlockBar? I'm using this library but no luck at showing the 3 dotted overflow menu. the min sdk is set to 9, the target sdk is set to 10. My device has a menu button. the overflow menu shows at the bottom only if I click the menu button of the device. Is there any workaround to show the overflow menu in the 3 dotted icon using actionbarsherlock? Thanks alot! – idish Jul 28 '13 at 21:01
  • @idish Set your target to 16 or whatever. I currently use 18 i.e. android:targetSdkVersion="18" The overflow menu will appear when it is needed. I'm still using actionbar sherlock to great effect – jamesc Jul 28 '13 at 22:34
  • @idish I added a note in my answer below, but first of all it requires that your device offer soft buttons, which some do not. And two, the targetSdkVersion needs set to 10 or below, as I explain in my answer. (Not as jamesw suggests that you can use anything, which is incorrect, for this software button hack anyway.) – Jon Adams Apr 07 '14 at 17:40

1 Answers1

5

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

But to answer your questions:

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

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

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

The following example Android OS API levels would 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 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

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.

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.

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.

Community
  • 1
  • 1
Jon Adams
  • 24,464
  • 18
  • 82
  • 120
  • Also keep in mind, newer devices often come with hardware-only buttons and no menu button. Therefore, even with this hack, the menu feature will not be accessible. It is now strongly advised to switch to an action bar. – Jon Adams Feb 20 '14 at 14:47
  • Oh!, I'm realy sorry, but because of such things I "love" android... Action bar is pretty fine. But If I switch to Fullscreen! overflow menu is no more accessible. (I have newer device with no HW menu button). Solution such third-party bars is a step back, if we have ActionBars in android implemented (!?) – Peter Oct 17 '14 at 13:34