2

Can someone explain to me what this container and false is for? I'm kinda new to Android Programming. I need light!

 View view = inflater.inflate(R.layout.top_section, container, false);
Piyush
  • 18,895
  • 5
  • 32
  • 63
Jude Maranga
  • 865
  • 2
  • 9
  • 27

1 Answers1

3

Here is the description of the function.

Parameters

parser XML dom node containing the description of the view hierarchy.

root Optional view to be the parent of the generated hierarchy (if attachToRoot is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToRoot is false.)

attachToRoot Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML.

To answer your question, the container will be used as parent or root view of the generated hierarchy. The "false" is the flag to tell the inflater if the inflated hierachy will be attached to the root parameter or the container.

Community
  • 1
  • 1
Christian Abella
  • 5,747
  • 2
  • 30
  • 42