Reputation: 696
I need to implement custom view in Fragment. So far I have accomplished to extend View class to draw on canvas and set it to activity following google example.
I would like to draw on canvas in fragment and problem is that I do not know how to inflate the view, because it is object but not xml file.
return inflater.inflate(R.layout.article_view, container, false);
Can somebody help me to understand and solve this problem?
Thanks
Upvotes: 3
Views: 2953
Reputation: 62189
As simple as this:
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return new YourCustomView(container.getContext());
}
Upvotes: 5