I'm using [MaterialShowcaseView](https://github.com/deano2390/MaterialShowcaseView) to show the user a quick tutorial, when they first start the app.

The problem I'm having is that I'm only able to get a view reference to the items in my action bar items when the user selects that item in onOptionsItemSelected.

i.e.

```
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.my_location:
            // User chose the "Favorite" action, mark the current item
            // as a favorite...
            ShowcaseConfig config = new ShowcaseConfig();
            config.setDelay(500); // half second between each showcase view

            MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(this, SHOWCASE_ID);

            sequence.setConfig(config);

            sequence.addSequenceItem(findViewById(R.id.action_my_location),
                    "This is button one", "GOT IT");
            sequence.start();
            Toast.makeText(MapsActivity.this, "My location action press", Toast.LENGTH_SHORT).show();

            return true;

        default:
            // If we got here, the user's action was not recognized.
            // Invoke the superclass to handle it.
            return super.onOptionsItemSelected(item);
    }
}

```

The above code works.

Is it possible to get a view reference in onCreateOptionsMenu? Everything else I've tried gives me a null object reference for the view.

I've tried [this answer](https://stackoverflow.com/a/9529346/966825) too, to no success. 

I should mention that for the actionBar I used android's [action bar tutorial](http://developer.android.com/training/appbar/setting-up.html).

Thanks guys.

EDIT:

This is what I've tried to do now:

```
@Override
    public void invalidateOptionsMenu() {
        super.invalidateOptionsMenu();

    }
    MenuItem mi;
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        mi = menu.findItem(R.id.action_my_location);
        new MaterialShowcaseView.Builder(this)
                .setTarget(mi.getActionView())
                .setDismissText("GOT IT")
                .setContentText("This is some amazing feature you should know about")
                .setDelay(300) // optional but starting animations immediately in onCreate can make them choppy
                .singleUse("101010110") // provide a unique ID used to ensure it is only shown once
                .show();
        return super.onPrepareOptionsMenu(menu);
}

```

Error: 

> 
> java.lang.NullPointerException: Attempt to invoke virtual method 'void
>  android.view.View.getLocationInWindow(int[])' on a null object
>  reference
> 
> 
>