Thursday, 20 August 2015

XML : TourGuide and MenuItem from Menu.xml

Im Trying to display the TourGuide (https://github.com/worker8/TourGuide/) for a MenuItem that is in a ToolBar

my main_menu.xml ->

       <item              android:id="@+id/action_search"              android:title="Busca"              android:icon="@drawable/abc_ic_search_api_mtrl_alpha"              app:actionViewClass="android.support.v7.widget.SearchView"                app:showAsAction="always"              ></item>              <item              android:id="@+id/action_facebook"              android:title="Facebook"              android:icon="@drawable/facebook"              app:showAsAction="always"></item>   <item   android:id="@+id/action_settings"   android:title="@string/action_settings"            app:showAsAction="never" />          <item              android:id="@+id/action_share"              android:title="Compartilhar APP"              android:icon="@drawable/abc_ic_menu_share_mtrl_alpha"              app:showAsAction="never"></item>    

for some reason i CANT use it on any other icons that doesnt have the "ActionViewClass" like the Search

The OnCreateOptions

  public boolean onCreateOptionsMenu(Menu menu) {          // Inflate the menu; this adds items to the action bar if it is present.          getMenuInflater().inflate(R.menu.menu_atividade_principal, menu);            MenuItem searchItem = menu.findItem(R.id.action_search);          settings = menu.findItem(R.id.action_settings);  ...  }    

if i use it in the searchItem.getActionView(); it work like this:

  TourGuide t1 = TourGuide.init(this).with(TourGuide.Technique.Click)                  .setPointer(new Pointer())                  .setToolTip(new ToolTip().setTitle("Settings").setDescription("Settingssssss ToolTip"))                  .setOverlay(new Overlay())                  .playOn(searchItem.getActionView());    

but if i use it for the settings

  .playOn(settings.getActionView());    

i get a null pointer, why? i've saw the ActionClass at the Search MenuItem .XML, but even if i try .getTitle or anything else on the settings, it return a null pointer, WHY?

PS: dont want the ShowCase, its deprecated, TourGuide is active!

No comments:

Post a Comment