Nandakumar R
Nandakumar R

Reputation: 1414

How To Enable Menu in a Custom Theme in Android?

I'm creating an Android app using the theme "noTitlebar" and all the design changes are done and approved. Now I need to add a menu, so I have to add title bar. But, if I change the theme, the whole design for pop up, border, etc. will be affected.

So I created a custom theme by extending the theme
"android:style/Theme.NoTitleBar".

I enabled the title by

<item name="android:windowNoTitle">false</item> 

Now I got the title bar, but menu is showing up. The control is not coming to

public boolean onCreateOptionsMenu(Menu menu) {

How can we enable menu in this theme? Help will be greatly appreciated.

Upvotes: 0

Views: 610

Answers (1)

Peter Knego
Peter Knego

Reputation: 80340

Since your are targeting Honeycomb (right?), when you say titlebar you probably mean Action Bar? Follow the link to read the docs.

In a nutshell:

  1. You need to set targetSdkVersion="11" and your build target (in eclipse) to v11.
  2. Just use Theme.Holo. Action bar is by default enabled. Theme.Holo is a default theme for v11 so you even don't need to define it.

Upvotes: 1

Related Questions