title: Dynamically adding inflated views to ViewFlipper in Android causes NullPointerException
body: <p>I'm getting <code>NullPointerException</code> when I'm trying to programmatically add inflated views to my <code>ViewFlipper</code>:</p>
  
  <p>-- onCreate</p>
  
  <pre><code>setContentView(R.layout.event_report);
  
  final LayoutInflater inflater = getLayoutInflater();
  mFlipper = (ViewFlipper) findViewById(R.id.eventReportViewFlipper);
  
  final View typeView = inflater
              .inflate(R.layout.event_report_type, null)
  mFlipper.addView(typeView, VIEW_TYPE, null); //NullPointerException
  </code></pre>
  
  <p>-- event_report.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:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@android:color/darker_gray"
      android:orientation="vertical"&gt;
      &lt;TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:background="@android:color/background_dark"
          android:gravity="center"
          android:text="@string/eventReportCaption"
          android:textAppearance="?android:attr/textAppearanceLarge"/&gt;
      &lt;ViewFlipper
          android:id="@+id/eventReportViewFlipper"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>-- event_report_type.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:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
      &lt;LinearLayout
          android:id="@+id/eventReportViewTypeUpperLayout"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_weight="1"
          android:orientation="horizontal"&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_weight="1"/&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_weight="1"/&gt;
      &lt;/LinearLayout&gt;
      &lt;LinearLayout
          android:id="@+id/eventReportViewTypeLowerLayout"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_weight="1"
          android:orientation="horizontal"&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_weight="1"/&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_weight="1"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I plan to initialize typeView later.</p>
  
  <p>Here's my stack trace:</p>
  
  <pre><code>11-28 16:59:56.280: E/AndroidRuntime(8604): Caused by: java.lang.NullPointerException
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at android.view.ViewGroup$LayoutParams.&lt;init&gt;(ViewGroup.java:3582)
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at android.view.ViewGroup$MarginLayoutParams.&lt;init&gt;(ViewGroup.java:3732)
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at android.widget.FrameLayout$LayoutParams.&lt;init&gt;(FrameLayout.java:492)
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:436)
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at android.view.ViewGroup.addViewInner(ViewGroup.java:1984)
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at android.view.ViewGroup.addView(ViewGroup.java:1874)
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at android.widget.ViewAnimator.addView(ViewAnimator.java:160)
  11-28 16:59:56.280: E/AndroidRuntime(8604):     at fi.emicode.flashpoint.EventDialog.onCreate(EventDialog.java:43)
  </code></pre>