title: Why using XML to create GUI is a good practice in Android
body: <p>I am from Java Swing background. May I know why using XML to create GUI is a good practice in Android? For instance, instead of writing the code in (Which makes me feel more comfortable with it as I use to Swing desktop application)</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.widget.TextView;
  
  public class HelloAndroid extends Activity {
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         TextView tv = new TextView(this);
         tv.setText("Hello, Android");
         setContentView(tv);
     }
  }
  </code></pre>
  
  <p>We write the code in XML way.</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  
  public class HelloAndroid extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      }
  }
  </code></pre>
  
  <p>In tutorial, it states that, </p>
  
  <blockquote>
    <p>This structure makes it very easy to
    quickly build up UIs, using a more
    simple structure and syntax than you
    would use in a programmatic layout.</p>
  </blockquote>
  
  <p>However, I don't really buy the idea, as I feel that creating a separate XML file is more cumbersome.</p>
  
  <p>Can anyone give a real world example (in the sense of Android), why using XML to build GUI is more superior than bare Java code? </p>
  
  <p><strong>If GUI programming through XML is really a good stuff, why it still hasn't become a common practice among GUI desktop application developers?</strong></p>