Menu item ID is not recognized

Posted by Alex Farber on Stack Overflow See other posts from Stack Overflow or by Alex Farber
Published on 2012-10-11T09:32:25Z Indexed on 2012/10/11 9:37 UTC
Read the original article Hit count: 421

Filed under:
|

menu/activity_main.xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menu_settings"
        android:title="@string/menu_settings"
        android:showAsAction="never" />
    <item android:id="@+id/menu_save_log"
        android:title="@string/menu_save_log"
        android:showAsAction="never" />
</menu>

MainActivity.java:

//@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.menu_settings:      // OK
        break;
    case R.id.menu_save_log:      // menu_save_log cannot be resolved or is not a field
        break;
    }

    return true;
}

Why menu_save_log is not recognized?

© Stack Overflow or respective owner

Related posts about android

Related posts about resources