2

I targeted the items in an action bar using ShowcaseView, but I can't target elements of a ListView! I tried that and it didn't work:

ShowcaseView sv = new ShowcaseView.Builder(this,true)
    .setTarget(new ViewTarget(lv.getChildAt(1).findViewById(R.id.heart)))
    // Here is where you supply the id of the action bar item you
    // want to display
    .setContentTitle("Heart")
    .setContentText("Check the venues of your city")
    .hideOnTouchOutside()
    .build();
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
carlos kekwa
  • 39
  • 1
  • 8

1 Answers1

1

Very simple. Take the element in your ViewHolder then place the code for showing the ShowCaseView inside your bindView.

Don't forget to put different a different ID for each element in the list.

So you may try something like this.

public class ViewHolder extends RecyclerView.ViewHolder {

  private TextView button;

  public ViewHolder(final View itemView) {
    super(itemView);
    button = (Button) itemView.findViewById(R.id.list_button);

    button.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        new MaterialShowcaseView.Builder(getActivity())
          .setTarget(verifyButton)
          .setDismissText("GOT IT")
          .setContentText("Your text goes here")
          .setDelay(100) // optional but starting animations immediately in onCreate can make them choppy
          .singleUse(id + " define an unique id for each item of the list") // provide a unique ID used to ensure it is only shown once
          .show();
        }
      });
    }
  }
}

To get more information you can check the library here.

Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98