Hello michael22,
the SDK provides the following function.
Using java Syntax Highlighting
ViewInflate.from(this).inflate(resourceID, rootViewGroup, attachToRoot, additionalInflateParamsMap);
Parsed in 0.030 seconds, using
GeSHi 1.0.8.4
Its description sounds as it will help you further. It goes as follows:
View android.view.ViewInflate.inflate(int resource, ViewGroup root, boolean attachToRoot, Map inflateParams)
public View inflate(int resource, ViewGroup root, boolean attachToRoot, Map inflateParams)
Inflate a new view hierarchy from the specified xml resource. Throws ViewInflate.InflateException if there is an error.
Parameters
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.
inflateParams Optional map of additional attribute name/value pairs to apply to the root element. Can be null. Currently, this parameter is only intended to be used internally by Android.
Returns
The root View of the inflated hierarchy. If root was supplied and attachToRoot is true, this is root; otherwise it is the root of the inflated XML file.
Let us know if it helped you.

Regards,
plusminus