开发者

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) {

H开发者_运维技巧ow can we enable menu in this theme? Help will be greatly appreciated.


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜