5

我找到了旧版本的示例,但没有找到新构建器模式的示例。有谁知道如何做到这一点?

4

1 回答 1

13

Builder 构造函数只需要一个活动public Builder(Activity activity),因此:

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();
    ....
于 2014-05-22T11:51:37.003 回答