Android: change fragment width programmatically in onConfigurationChanged
<p>Trying to change fragment width when user rotate device to landscape mode</p>

<p>That is my fragment:</p>

<pre><code>    &lt;fragment
        android:id = "@+id/menu"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        class="myPackage.MenuFragment" /&gt;
</code></pre>

<p>And that is my onConfigurationChanged method:</p>

<pre><code>@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    setContentView(R.layout.main);
    findViewById(R.id.menu).getLayoutParams().width = (int) (getWindowManager()
            .getDefaultDisplay().getWidth());
}
</code></pre>

<p>But when I rotate device the output is crash:</p>

<blockquote>
  <p>05-14 03:00:51.379: E/AndroidRuntime(3117): FATAL EXCEPTION: main
  05-14 03:00:51.379: E/AndroidRuntime(3117):
  android.view.InflateException: Binary XML file line #13: Error
  inflating class fragment 05-14 03:00:51.379: E/AndroidRuntime(3117):
    at
  android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:582)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  android.view.LayoutInflater.rInflate(LayoutInflater.java:621) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  android.view.LayoutInflater.inflate(LayoutInflater.java:407) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  android.view.LayoutInflater.inflate(LayoutInflater.java:320) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  android.view.LayoutInflater.inflate(LayoutInflater.java:276) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  android.app.Activity.setContentView(Activity.java:1654) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  softserveinc.dbyst.reveal.Reveal_prototypeActivity.onConfigurationChanged(Reveal_prototypeActivity.java:71)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:4153)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:4246)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:2215)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  android.os.Handler.dispatchMessage(Handler.java:99) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  android.os.Looper.loop(Looper.java:143) 05-14 03:00:51.379:
  E/AndroidRuntime(3117):   at
  android.app.ActivityThread.main(ActivityThread.java:4914) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  java.lang.reflect.Method.invokeNative(Native Method) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  java.lang.reflect.Method.invoke(Method.java:521) 05-14 03:00:51.379:
  E/AndroidRuntime(3117):   at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  dalvik.system.NativeStart.main(Native Method) 05-14 03:00:51.379:
  E/AndroidRuntime(3117): Caused by: java.lang.IllegalArgumentException:
  Binary XML file line #13: Duplicate id 0x7f050001, tag null, or parent
  id 0x0 with another fragment for myPackage.MenuFragment 05-14
  03:00:51.379: E/AndroidRuntime(3117):     at
  android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:275)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   at
  android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
  05-14 03:00:51.379: E/AndroidRuntime(3117):   ... 19 more</p>
</blockquote>

<p>What i'v done wrong ?</p>
