I have this code in my main activity for the fragments.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainView"
android:orientation="vertical"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mainView2"/>
</LinearLayout>
And i use this code in my main activity to inflate the fragments
FragmentManager fm = getSupportFragmentManager();
fm.beginTransaction().add(R.id.mainView,new MainViewFragment())
.add(R.id.mainView2,new SecondProductLayout())
.commit();
But i'm still getting the 1st fragments view, what am i doing wrong and how can i fix this problem?