can someone explain me the difference between:
onMenuItemSelected (int featureId, MenuItem item)
http://developer.android.com/reference/android/app/Activity.html#onMenuItemSelected%28int,%20android.view.MenuItem%29
and
onOptionsItemSelected (MenuItem item)
http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected%28android.view.MenuItem%29
in Android? I found a tutorial were someone overrides both methods.
// Reaction to the menu selection
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case R.id.insert:
createTodo();
return true;
}
return super.onMenuItemSelected(featureId, item);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.insert:
createTodo();
return true;
}
return super.onOptionsItemSelected(item);
}
Source: http://www.vogella.de/articles/AndroidSQLite/article.html
Android knows about several types of menus (e.g. Options Menu and Context Menu).
onMenuItemSelectedis the generic callback. You don’t need to use this usually.onOptionsItemSelectedis the callback of the options menu andonContextItemSelectedis the callback of the context menu. Use these two specific ones instead.