Conditionally switch between layouts in Android
<p>How do you switch between layouts in an activity and populate fields based on layout currently used?</p>

<p>For example if there is a logic in a view to load a view:</p>

<pre><code>  if(category == 1){ 
      setContentView(R.layout.layout1);
  }else{
      setContentView(R.layout.layout2);
    TextView title = (TextView) findViewById(R.id.titleTV);
      title.setText("myTitle");

  }
</code></pre>

<p>If the else code is called the view never sets the title TextView to the String.</p>

<p>How do I accomplish conditionally going between the two views?</p>
