android.app.Activity.getLayoutInflater() or
android.content.Context.getSystemService(java.lang.String) to retrieve a standard LayoutInflater instance
that is already hooked up to the current context and correctly configured
for the device you are running on. For example:
LayoutInflater inflater = (LayoutInflater)context.getSystemService
Context.LAYOUT_INFLATER_SERVICE);
To create a new LayoutInflater with an additional for your
own views, you can use LayoutInflater.Factory to clone an existing
ViewFactory, and then call cloneInContext(android.content.Context) on it to include your
Factory.
setFactory(android.view.LayoutInflater.Factory)
For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime; it only works with an XmlPullParser returned from a compiled resource (R.something file.)
Note that it is good practice to prefix these custom names with your package (i.e., com.coolcompany.apps) to avoid conflicts with system names.
name Tag name to be inflated.context The context the view is being created in.attrs Inflation attributes as specified in XML file.Context.getSystemService() to retrieve
the standard Context.INFLATER_SERVICE.
context The Context in which this LayoutInflater will create its
Views; most importantly, this supplies the theme from which the default
values for their attributes are retrieved.cloneInContext(android.content.Context).
original The original LayoutInflater to copy.newContext The new Context to use.ContextThemeWrapper to create a new LayoutInflater to go along
with the new Context theme.
newContext The new Context to associate with the new LayoutInflater.
May be the same as the original Context if desired.onCreateView(java.lang.String,android.util.AttributeSet) method is called.
If you have an existing
LayoutInflater and want to add your own factory to it, use
to clone the existing instance and then you
can use this function (once) on the returned new instance. This will
merge your own factory with whatever factory the original instance is
using.
cloneInContext(android.content.Context)
LayoutInflater.Filter currently used by this LayoutInflater to restrict the set of Views
that are allowed to be inflated.LayoutInflater.Filter to by this LayoutInflater. If a view is attempted to be inflated
which is not allowed by the LayoutInflater.Filter, the inflate(int,android.view.ViewGroup) call will
throw an InflateException. This filter will replace any previous filter set on this
LayoutInflater.
filter The Filter which restricts the set of Views that are allowed to be inflated.
This filter will replace any previous filter set on this LayoutInflater.InflateException if there is an error.
resource ID for an XML layout resource to load (e.g.,
R.layout.main_page)root Optional view to be the parent of the generated hierarchy.InflateException if there is an error. *
Important   For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime.
parser XML dom node containing the description of the view
hierarchy.root Optional view to be the parent of the generated hierarchy.InflateException if there is an error.
resource ID for an XML layout resource to load (e.g.,
R.layout.main_page)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.InflateException if there is an error.
Important   For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime.
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.There are two things that can happen in an error case: either the exception describing the error will be thrown, or a null will be returned. You must deal with both possibilities -- the former will happen the first time createView() is called for a class of a particular name, the latter every time there-after for that class name.
name The full name of the class to be instantiated.attrs The XML attributes supplied for this instance.name The fully qualified class name of the View to be create.attrs An AttributeSet of attributes to apply to the View.