include 2 fragments inside one activity
<p>I have 2 fragments: <code>ls_fragment</code> and <code>pm_fragment</code>. I'm trying to show the <code>pm_fragment</code> in the portrait mode and both fragments in the landscape mode, but my code doesn't work as well. In the portrait mode it works and show <code>pm_fragment</code>, but in the landscape mode it shows only one fragment(the <code>lm_fragment</code>).</p>

<p>MainActivity code:</p>

<pre><code>public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    //        setContentView(R.layout.activity_main);

        Configuration config = getResources().getConfiguration();

        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction =
                fragmentManager.beginTransaction();

        LM_Fragment lm_fragment = new LM_Fragment();
        PM_Fragment pm_fragment = new PM_Fragment();

        /**
         * Check the device orientation and act accordingly
         */
        if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            /**
             * Landscape mode of the device
             */
            fragmentTransaction.replace(android.R.id.content, lm_fragment);
            fragmentTransaction.add(android.R.id.content, pm_fragment);
          //fragmentTransaction.replace(android.R.id.content, pm_fragment);
        }else{
            /**
             * Portrait mode of the device
             */
            fragmentTransaction.replace(android.R.id.content, pm_fragment);
        }
        fragmentTransaction.commit();
    }
}
</code></pre>

<p>and <code>LM_Fragment</code> class (looks like <code>PM_Fragment</code> class):</p>

<pre><code>public class LM_Fragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        /**
         * Inflate the layout for this fragment
         */
        return inflater.inflate(
                R.layout.lm_fragment, container, false);
    }
}
</code></pre>

<p>activity_main.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"&gt;

    &lt;framelayout
        android:name="com.example.myfragments.LM_Fragment"
        android:id="@+id/lm_fragment"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="match_parent" /&gt;

    &lt;framelayout
        android:name="com.example.myfragments.PM_Fragment"
        android:id="@+id/pm_fragment"
        android:layout_weight="2"
        android:layout_width="0dp"
        android:layout_height="match_parent" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>lm_fragment.xml(look like pm_fragment.xml)</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#7bae16"&gt;

    &lt;TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/landscape_message"
    android:textColor="#000000"
    android:textSize="20px" /&gt;

    &lt;!-- More GUI components go here  --&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>how can I show both of fragment in landscape?</p>