finditem() doesn't find menu, stuck with NullPointerException

Posted by fdansv on Stack Overflow See other posts from Stack Overflow or by fdansv
Published on 2012-10-18T02:54:30Z Indexed on 2012/10/18 5:03 UTC
Read the original article Hit count: 155

I'm stuck while changing some properties on my options menu at onCreateOptionsMenu(). It seems like findItem() returns null, even though I'm pretty sure that the reference to the menu item is correct. My code looks as follows:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_profile, menu);
        MenuItem leftie = menu.findItem(R.id.menu_profile);
        leftie.setIcon(R.drawable.ic_menu_mapmode);
        leftie.setTitle(R.string.back_map);
        leftie.setIntent(authIntent);

        return true;
    }

I really don't know what can be wrong there. Thanks in advance :)

EDIT: I forgot to include the actual problem.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-layout