Reputation: 12727
The description of container parameter for function onCreateView of fragment class says :
container : If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view.
does the line
The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view
mean that container.addView(some_view)
is not permitted?
Upvotes: 3
Views: 579
Reputation: 1007296
Correct. You would use this parameter in a call to inflate()
on a LayoutInflater
(e.g., inflater.inflate(R.layout.frag, container, false);
) or to determine what LayoutParams
are needed if you are creating your fragment contents directly via Java instead of inflation. Otherwise, the container is owned by the hosting activity, and your fragment should leave it alone, AFAIK.
Upvotes: 4