java - how to Call Android Layout(XML) Programmatically? -
i want call android layout(xml) programmatically in function. layout created in xml. asking question because don't want use in android native app, call these layouts in unity3d gaming engine. let have layout. example @ below code:
<linearlayout android:layout_width="0dp" android:layout_height="wrap_content" android:orientation="vertical"> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/useful_nums_item_name"/> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/useful_nums_item_value"/> </linearlayout> <imagebutton android:layout_width="0dp" android:layout_height="wrap_content" android:src="@drawable/call" android:id="@+id/call_btn" android:onclick="callnumber"/> </linearlayout>
now want create function can call layout. but don't want use below code not going use in android native app.
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); }
i directly use unity3d class below:
public class mainactivity extends unityplayeractivity { }
so need call layout in class in form of function. example:
public class mainactivity extends unityplayeractivity { public void showlayout(){ enter code here } }
so need people solve problem.
any appreciated.
take layout use of inflator
, bring on front.
layoutinflater inflater = layoutinflater.from(context); view yourview = inflater.inflate(r.layout.popup_layout, null, false); // bring front yourview.bringtofront();
Comments
Post a Comment