Looked for a long time, finally found.
<?XML version= "1.0" encoding= "UTF-8"?><Mergexmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:okcancelbar= "Http://schemas.android.com/apk/res/com.example.android.merge"> <ImageViewAndroid:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:scaletype= "Center"android:src= "@drawable/golden_gate" /> <Com.example.android.merge.OkCancelBarAndroid:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"android:layout_gravity= "Bottom"Android:paddingtop= "8dip"android:gravity= "Center_horizontal"Android:background= "#AA000000"Okcancelbar:oklabel= "Save"Okcancelbar:cancellabel= "Don ' t Save" /></Merge>
Com.example.android.merge.OkCancelBar is a custom group
Public classOkcancelbarextendslinearlayout{ PublicOkcancelbar (Context context,attributeset attrs) {Super(context, attrs); SetOrientation (horizontal); Setgravity (Gravity.center); Setweightsum (1.0f); Layoutinflater.from (context). Inflate (R.layout.okcancelbar, This,true); TypedArray Array= Context.obtainstyledattributes (Attrs, r.styleable.okcancelbar,0,0); String text=array.getstring (R.styleable.okcancelbar_oklabel); if(text==NULL) text= "OK"; (Button) Findviewbyid (R.ID.OKCANCELBAR_OK)). SetText (text); Text=array.getstring (R.styleable.okcancelbar_cancellabel); if(text==NULL) text= "Cancel"; (Button) Findviewbyid (R.id.okcancelbar_cancel)). SetText (text); Array.recycle (); }}
Layoutinflater.from (context). Inflate (r.layout.okcancelbar,this,true);
Get a view from the XML directly into the current group
Okcancelbar.xml:
<Mergexmlns:android= "Http://schemas.android.com/apk/res/android"><includeLayout= "@layout/okcancelbar_button"Android:id= "@+id/okcancelbar_ok"/><includeLayout= "@layout/okcancelbar_button"Android:id= "@+id/okcancelbar_cancel"/></Merge>
Example of a usage of Android--viewgroup (reproduced)