Alexandr Sulimov
Alexandr Sulimov

Reputation: 1924

Menu button 2.3 and 4.0

Application must be run on 2.3 and 4.0. On activity there are options menu. On 2.3 - all ok present menu button on device. On 4.0 - no menu button, an no way show option menu. in manifest

android:minSdkVersion="8"
android:targetSdkVersion="15" />

activity

public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.activity_auth, menu);
  return true;
}

Q: How write application for run on 2.3 and 4.0, and using options menu?

Upvotes: 0

Views: 2207

Answers (3)

SachinGutte
SachinGutte

Reputation: 7055

It's huge pain in making app compatible with older versions. There's one library I will suggest you to use. It damn good written by Jake Wharton called ActionBarSherlock. You can find out more here at the link

I myself used in two apps till now. It allows you to use ActionBar (introduced in 3.0) in older versions like 2.2. It extends android support-library There are themes provided in library and if set your app simple transforms into 4.0 in terms of look and feel.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006539

How write application for run on 2.3 and 4.0, and using options menu?

Besides what you have already done, you need to have an action bar on API Level 11+, which will have a three-dots affordance to display the overflow menu (where all your options menu items will go that you have not put into the action bar itself). You should have an action bar by default given your existing android:targetSdkVersion="15".

For devices that have an off-screen MENU button, though, you will not see the three-dots affordance in the action bar. Instead, the user will need to press the MENU button to display your menu, just as they do on Android 2.3.

Upvotes: 3

Marcin Orlowski
Marcin Orlowski

Reputation: 75619

Lower your targetSdk to 10 (or lower)to legacy menu button to reappear.

And I strongly suggest you read this article Say Goodbye to menu button to undestand all the logic behind...

Upvotes: 0

Related Questions