title: Adding VideoView to an XML layout
body: <p>I would like to programmatically add a VideoView to a LinearLayout. The LinearLayout has an id of "main". </p>
  
  <p>Referencing this SO question <a href="https://stackoverflow.com/questions/4200011/video-streaming-and-android">Video Streaming and Android</a>, I was able to get the video to show up and play, but what if I wanted to create a new VideoView on the fly and add it to the layout?</p>
  
  <p>This is the XML I am trying to "copy" programmatically:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout android:id="@+id/main"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"&gt;
  &lt;VideoView android:id="@+id/your_video_view"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
  /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here is how I tried to accomplish the same thing programmatically:</p>
  
  <pre><code>VideoView videoView = new VideoView(this);
  LinearLayout layout = (LinearLayout)findViewById(R.id.main);
  LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  layout.addView(videoView, params);
  </code></pre>
  
  <p>The problem is that the video doesn't show up at all! With VideoView declared in XML, everything works fine, but programmatically, it doesn't work at all.</p>
  
  <p>To be clear, I do not want to have a VideoView defined in the XML file when I am doing it programmatically.</p>