i have an root_layout :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background"
android:weightSum="10">
<FrameLayout
android:id="@+id/parentViewHolder"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="8"
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent" >
</FrameLayout>
<TextView
android:id="@+id/spaceHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="TEXT">
</TextView>
Now i want, everytime i want to change the screen, that these layout is used and filled with an other declared layout.xml
I tried to use
protected void Setup(int _layoutResourceId)
{
layoutResourceId = _layoutResourceId;
FrameLayout holder = (FrameLayout) activity.findViewById(R.id.parentViewHolder);
LayoutInflater layoutInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
holder.addView(layoutInflater.inflate(layoutResourceId, null, false));
activity.screen = this;
}
But this didn’t work fine.Did anyone knows a nicer implementation?
If you want to add a different layout to the
FrameLayoutfrom the layout that you posted, this is how you should do it: