I use MaterialShowcaseView to show the user a quick tutorial the first time the application starts.
The problem I am facing is that I can get a link to the links to the elements in the elements of the action bar when the user selects this element in onOptionsItemSelected.
i.e.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.my_location:
ShowcaseConfig config = new ShowcaseConfig();
config.setDelay(500);
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:
return super.onOptionsItemSelected(item);
}
}
The above code works.
Can I get a view link in onCreateOptionsMenu? Everything I tried gives me a reference to a null object for presentation.
I already tried this answer without succeeding.
I should mention that for the actionBar I used the android bar tutorial .
Thanks guys.
EDIT:
Here is what I 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)
.singleUse("101010110")
.show();
return super.onPrepareOptionsMenu(menu);
}
:
java.lang.NullPointerException: 'void android.view.View.getLocationInWindow(int []) '