Adding Layout to a ViewGroup Android -
i have flying in menu based on viewgroup. want there basic layout , in activity able insert view group new layout , afterwards erase it. but doesn't work!!! can me please.
class:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.root = (flyoutcontainer) this.getlayoutinflater().inflate(r.layout.activity_main, null); this.setadditionallayout(findviewbyid(r.id.physical_layout)); this.setcontentview(root); }
viewgroup:
<com.nurielweizmann.calculator.view.viewgroup.flyoutcontainer xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#444488" android:orientation="vertical" android:id="@+id/menu"> ............ </relativelayout> </com.nurielweizmann.calculator.view.viewgroup.flyoutcontainer>
function:
flyoutcontainer root; public void setadditionallayout(view view){ root.addview(view,1); }
thanks in advance
try overriding setcontentview(int)
instead of oncreate(bundle)
.
make sure base layout xml has viewgroup
(framelayout
, example) available put each activity
's content.
when overriding setcontentview(int)
, inflate base layout first inflate activity
's layout , place activity
's layout on framelayout
available.
Comments
Post a Comment