how do you use the second parameter in the inflate method of the LayoutInflater class, Android -
the inflate method of layoutinflater
abstract class has second parameter of inflate method takes viewgroup
root. documentation, mentioned "optional view parent of generated hierarchy."
can give example on how use parameter? , put in there? viewgroup
can type of layout linearlayout
.
i have not quite understood parameter. if view inflating not part of layout entered here give error. don't understand purpose of it.
more documentation:
public view inflate (xmlpullparser parser, viewgroup root)
added in api level 1 inflate new view hierarchy specified xml node. throws inflateexception if there error.
important performance reasons, view inflation relies heavily on pre-processing of xml files done @ build time. therefore, not possible use layoutinflater
xmlpullparser
on plain xml file @ run time.
parameters parser xml dom node containing description of view hierarchy.
root optional view parent of generated hierarchy. returns root view of inflated hierarchy. if root supplied, root view; otherwise root of inflated xml file.
i'm not sure part of confuses you, honest. can pass in viewgroup, parent of views you're creating dynamically.
for example:
private static view mview = inflater.inflate(r.layout.fragment_featured, container, false);
this inflate layout contained in fragment_featured xml file within container (as parent). type of container viewgroup you.
Comments
Post a Comment