I found examples for the legacy version, but not for the new builder pattern. Does anyone know how to do this?
Asked
Active
Viewed 2,666 times
1 Answers
13
The Builder constructor only needs an activity public Builder(Activity activity)
so:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment, container, false);
showcaseView = new ShowcaseView.Builder(getActivity())
.setTarget(new ViewTarget(view.findViewById(R.id.textView)))
.setOnClickListener(listener)
.build();
....

Stephan
- 15,704
- 7
- 48
- 63
-
1This would work for an activity, but not for a fragment... I can only `getActivity()` in `onActivityCreated()`, but there I can't `findViewById()` (the views aren't measured yet so I'll get an exception `java.lang.IllegalArgumentException: width and height must be > 0`). – Michael Litvin May 22 '14 at 11:54
-
3@MichaelLitvin that's why you have to do it in the `onCreateView` method. I just updated my answer. – Stephan May 22 '14 at 11:59
-
1Thanks guys, I'll update the sample and example code to show how to do this for other users! – Alex Curran May 22 '14 at 17:10