mardi 4 août 2015

Getting a NPE with AppCompatActivity that I wasn't getting with ABS

In my onCreateOptionsMenu() I'm getting a View v that is ending up null. I can put a null check around it, but it won't actually solve the issue since I need to use that view further on in the method. The code causing v to be null is below:

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);


        /** Create an option menu from res/menu/items.xml */
        getMenuInflater().inflate(R.menu.dee, menu);
        View v = (View) menu.findItem(R.id.search_menu_item).getActionView();

Any reason why seemingly changing the Activity to use AppCompat instead of ABS is causing a null pointer?

Aucun commentaire:

Enregistrer un commentaire