Skip to content

Instantly share code, notes, and snippets.

@macdonst
Created November 5, 2012 03:22
Show Gist options
  • Save macdonst/4015145 to your computer and use it in GitHub Desktop.
Save macdonst/4015145 to your computer and use it in GitHub Desktop.
PhoneGap Android Native Menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.example, menu);
return true;
}
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/settings"
android:icon="@drawable/settings"
android:title="@string/settings"/>
<item android:id="@+id/help"
android:icon="@drawable/help"
android:title="@string/help" />
</menu>
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.settings:
this.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
return true;
case R.id.help:
this.appView.sendJavascript("navigator.notification.alert('No help')");
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment