title: Dynamic vs XML layout in Android?
body: <p>I'm new to Android development and have started creating my own UI. I see that you can either create it dynamically something like this (<a href="http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/">Dynamic Layouts</a>):</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      ScrollView sv = new ScrollView(this);
      LinearLayout ll = new LinearLayout(this);
      ll.setOrientation(LinearLayout.VERTICAL);
      sv.addView(ll);
      TextView tv = new TextView(this);
      tv.setText("Name");
      ll.addView(tv);
      EditText et = new EditText(this);
      ll.addView(et);
      Button b = new Button(this);
      b.setText("Ok");
      ll.addView(b);
  }
  </code></pre>
  
  <p>but I also see that netbeans has a file <em>Resources->layout->main.xml</em>. So you can create an XML layout for the UI (<a href="http://developer.android.com/guide/topics/ui/declaring-layout.html">Declaring XML layout</a>):</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="fill_parent"
      android:layout_height="fill_parent"
      &gt;
  &lt;TextView  
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Hello World, AndroidTest"
      /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>So my question is which should I use? what is recommended and what are the pros/cons of dynamic vs XML layouts in Android development?</p>