Casper
Casper

Reputation: 373

Monodroid ActionBar show menubutton on Galaxy

I need to show the menu button, in the ActionBar, even if it has a hardware key.

I found this in android:

try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if(menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

But how to convert it to monodroid? I can't get the getDeclaredField method.

Thanks.

Upvotes: 0

Views: 188

Answers (1)

Cheesebaron
Cheesebaron

Reputation: 24460

You can use:

ViewConfiguration.Get(Context).HasPermanentMenuKey

HasPermanentMenuKey is a bool, which you can use to find out whether the device has a permanent menu key. However you need to set minimum API level to 14 to have this working.

Upvotes: 1

Related Questions