Recently, when using the view inflate (context context, int resource, ViewGroup root) method, a bit of trouble was encountered on the third parameter root.
Custom columns are typically loaded when you write the adapter of a ListView
NULL );... viewgroup.addview (imagelayout);
If this is the case, there may be a problem when calling Imagelayout
// add layout to ViewGroup when inflate View imagelayout = Inflate (GetContext (), R.layout.item_album_pager, ViewGroup);
This is because the Inflate method returns the root of the view when the third parameter root is not empty, and when root is empty, the node that is the loaded layout is returned. Look at the API explanation:
New from if is for A is is the root of the inflated XML file.
I was in the Viewpager of the adapter, using the root is not empty inflate method, return to layout error.
@Override Public int position) { = Inflate (GetContext (), R.layout.item_album_pager, viewgroup); .... // this actually returns the entire viewgroup, causing an error. return imagelayout; }
Here is an example of the inflate method that comes with the view class, which essentially invokes the Layoutinflater Class View inflate (int resource, ViewGroup root) method.
Public Static int resource, ViewGroup root) { = Layoutinflater. from (context); return Factory.inflate (resource, root); }
Android about inflate root parameter