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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With