MagicConch
MagicConch

Reputation: 109

onPrepareOptionsMenu used in Android

I want to use android menu function.
And I already set onPrepareOptionsMenu(),
and set the content.
But I have problem, that my pad has no menu icon to click.
Do I need to set anymore?

Upvotes: 1

Views: 902

Answers (5)

Mohamad Bdour
Mohamad Bdour

Reputation: 450

The overflow option menu icon (looks like 3 dots) at top-right corner will not appear if your device has a hardware menu key.

Your device must be at least on 3.x.

Upvotes: 1

Opiatefuchs
Opiatefuchs

Reputation: 9870

Since Android 3.0 (Honeycomb), that was made especially for tablets, there is no more hardware menu button (but phones still got one), so to use ActionBar for tablets, You could follow this tutorial:

http://www.dreamincode.net/forums/topic/274639-android-actionbar-tutorial/

and read this too:

http://developer.android.com/guide/topics/ui/actionbar.html

Upvotes: 1

hardartcore
hardartcore

Reputation: 17037

If you set android:targetSdkVersion bigger than 10 and you are using theme NoTitleBar in the devices which are running Android 3+ and which don't have menu button there won't show a software menu button next to back button. If you want that option to be enabled set your targetSdkVersion to 10 and test i your device if there will show the software menu button.

Upvotes: 0

Zoombie
Zoombie

Reputation: 3610

Instead of using

onPrepareOptionsMenu(),

which is for updating text and other thing once menu option is created, use

public boolean onCreateOptionsMenu (Menu menu)

and selection of menuitem can be achieved by

public boolean onOptionsItemSelected (MenuItem item)

Many examples can be found for menu creation,updation and selection.

Upvotes: 0

Pratik
Pratik

Reputation: 30855

In tablet you have implement ActionBar in your activity. For enable and use of ActionBar you must have to use Titlebar for your activity. Just create the Theme in style.xml having Title bar and store in value-xlarge dir for large screen. And get the ActionBar object by using this getActionBar().

Note: You must have to use API 11 or above if you have minSDK below 11 then you have check version of OS

Upvotes: 0

Related Questions