akshay
akshay

Reputation: 5979

how to get menu options in android api level 17 devices?

I am having an application which contains Menu options, but in some of Jelly Bean devices we don`t have the Menu soft key button so in that case how can I show those menu options? Do I need to check sdk version, based on which I have to implement functionality? and I am unable to use hasPermanentMenuKey() function in my app.
My app targets

android:minSdkVersion="9"
android:targetSdkVersion="17"

Can anyone give me any suggestions?

Upvotes: 1

Views: 958

Answers (3)

Vasanth
Vasanth

Reputation: 6375

I think, you must have given android-9 specific theme in Android Manifest. Example android:theme="@android:style/Theme.Light"

1) Since Android 4.0 we have Action Bar, so many of the device running Android 4.0 and above will not have Hardware Menu.
2) All your Menu will be in action bar.
3) So, you need to specify different theme to Android v-14 and above, for you app to display Action bar with your menu.otherwise you will not get Action bar so as you Menu.

How To Do It
1) In values/styles.xml 
    <resources>
        <style name="AppBaseTheme" parent="android:Theme.Light"></style>
            <style name="AppTheme" parent="AppBaseTheme"> </style>
    </resources>

2) In values-v14/styles.xml
    <resources>
         <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style>
    </resources>

3) In AndroidManifest.xml
      android:theme="@style/AppTheme" 

Upvotes: 1

vamsiampolu
vamsiampolu

Reputation: 6622

Since the ActionBar was introduced in HoneyComb the menu you set using the onCreateOptionsMenu is displayed on the ActionBar of the activity.If you specify the android:showAsAction="never|withText" the item goes into the overflow menu...something which looks like three dots and is displayed with it's full text.

You can use the same API you use in pre HoneyComb:

    boolean onCreateOptionsMenu(Menu menu)
    boolean onOptionsItemSelected(MenuItem item)

Upvotes: 0

stinepike
stinepike

Reputation: 54672

use a lower minSDKVersion. Then in those set there will be a soft key for option menu too. for example

android:minSdkVersion="5"

Upvotes: 0

Related Questions