Skip to content

Instantly share code, notes, and snippets.

@macdonst
Created November 9, 2012 20:29
Show Gist options
  • Save macdonst/4048040 to your computer and use it in GitHub Desktop.
Save macdonst/4048040 to your computer and use it in GitHub Desktop.
Context Menu Example
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
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.onContextItemSelected(item);
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
this.registerForContextMenu(this.appView);
super.loadUrl("file:///android_asset/www/index.html");
}
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.example, menu);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment