user899641
user899641

Reputation: 351

Menu not working

Working with a Xoom Tablet and the menu(options) button on the bottom of the screen does not light up (is not active).

Any suggestions?

@Override
public boolean onCreateOptionsMenu (Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.option_menu, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection    
    switch (item.getItemId()) {    
    case R.id.about:   
        about();        
        return true;    
    default:        
        return super.onOptionsItemSelected(item);    
    }
}
private void about() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("About");
    alertDialog.setMessage("App v1.0");
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int which) {
          // here you can add functions
       }
    });
    alertDialog.setIcon(R.drawable.icon);
    alertDialog.show();

}

Upvotes: 0

Views: 252

Answers (2)

user899641
user899641

Reputation: 351

I figured it out..

My target and min Sdk was:

android:targetSdkVersion="11"

android:minSdkVersion="11"

Changed to:

android:targetSdkVersion="11"

android:minSdkVersion="10"

Menu button doesn't work on 11 and up.

Upvotes: 0

adamp
adamp

Reputation: 28932

The menu key shown on the system bar in Android 3.0+ is a compatibility feature for running older apps. Setting targetSdkVersion="10" means you are not developing an app that targets Android 3.0+ and the system will adjust compatibility behavior for your app accordingly.

If you are truly writing an app to run on Android 3.0+ tablets you will not have a menu key on the system bar. Forget about it. Put it out of your mind. :) Abusing compatibility features in this way explicitly breaks Android UI design guidelines. The action bar will present your activity's options menu if present. If you do not have an action bar in your activity you should present options using some other on-screen affordance.

Upvotes: 1

Related Questions