I'm running google maps API V2 as FragmentActivity.
May activity layout is here: activity_landing.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_gravity="center">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
PROBLEM: I want to dynamically add a fragment to this layout FrameLayout.
Here is my activity code:
BuildingPageFragment buildingFragment = new BuildingPageFragment();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.fragment_container, buildingFragment, "buildingPageFragment");
fragmentTransaction.commit();
Here is the fragments layout that I am trying to add the the FrameLayout in activity_landing.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical"
android:background="#FFBB00">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="BUILDING PAGE"
android:id="@+id/textView"
android:layout_gravity="center_horizontal" />
</LinearLayout>
The Fragment is not shoing on top of the to the fragment in the activity_landing.xml.
I am new to android dev so what am I missing? Thanks