3

not sure if the title is correct, but here's what I need. I have Xperia V, and as I guess, like most new phones, it does not have any buttons on the phone, but instead they appear on the display itself, the Home, Back and something like Tasks, dont know... What I want to know is how do I add a menu button next to these 3 buttons in an app, you know when there is a title bar in the app it appears up there, but with no title bar this menu button (its 3 dots) must be next to the other software buttons. How can I do it in my app?

Sartheris Stormhammer
  • 2,534
  • 8
  • 37
  • 81

2 Answers2

1

For starters, you will get a lot of people telling you here that this is a bad idea, and an old UI pattern. They are right...

Here is my answer on a related question - and also lots of other opinions on the topic (some quite amusing):

I particularly enjoy Compatibility Menu of Shame reference from @nicopico's answer.

Please consider if you really want it - only use in extreme cases, like maybe your client is insisting. Otherwise avoid this pattern.


You can set your build target to a version before ICS (i.e. up to and including API 13 / HoneyComb 3.2).

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="13" />

That will get the system to use a compatibility mode setting that inserts an overflow icon into your phone's bottom button bar - this should provide the functionality you are after. Pressing this button will have the same response as pressing a "menu" button on the Samsung Galaxy S2 for example.


Here you can see the compatibility "options" button, and the menu that has been shown when it was pressed:

ICS compatibility options button on Galaxy Nexus


Note:

As other commentators mention, you should consider the better choice of the ActionBar pattern. If you want backwards compatibility, then I recommend the Action Bar Sherlock library.

But if you are looking for a quick fix, or the client can't afford a big refactor to move to the Action Bar pattern, then this is the way to do it.

Community
  • 1
  • 1
Richard Le Mesurier
  • 29,432
  • 22
  • 140
  • 255
  • I recommend to read this: http://android-developers.blogspot.sk/2012/01/say-goodbye-to-menu-button.html – Koso Jul 10 '13 at 07:31
1

In your AndroidManifest you have to set the targetSdkVersion to 13 or earlier : <uses-sdk android:targetSdkVersion="13" /> .This will force ICS to run application in compatibility mode and to show 3 dots in system bar for overflow menu. But as koso and Richard Le Mesurier said this is a VERY bad idea. You should use Action Bar pattern or Fly-In App Menu pattern (Slide Menu) for this purposes.

Oleksandr Karaberov
  • 12,573
  • 10
  • 43
  • 70