开发者

Menu not working

开发者 https://www.devze.com 2023-04-02 17:50 出处:网络
Working with a Xoom Tablet and the menu(options) button on the bott开发者_C百科om of the screen does not light up (is not active).

Working with a Xoom Tablet and the menu(options) button on the bott开发者_C百科om 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();

}


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.


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.

0

精彩评论

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