title: how to use setContentView in android?
body: <p>I am new to android development, i want to use setContentView to change between two layouts, i have made two activities and two layouts, the first button "b1" successfully switches to second layout but the second button "b2" doesn't do anything
  Here is the code : </p>
  
  <blockquote>
  <pre><code>public class MainActivity extends Activity {
    Button b1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        b1 = (Button) findViewById(R.id.b1);
        b1.setOnClickListener(new OnClickListener() {
  
            @Override
            public void onClick(View v) {
  
                setContentView(R.layout.activity_second);
            }});}}
  </code></pre>
  </blockquote>
  
  <p>// --</p>
  
  <blockquote>
  <pre><code>public class second extends Activity{
    Button b2;
    protected void onCreate(Bundle saveInstanceState)
    {
        super.onCreate(saveInstanceState);
        setContentView(R.layout.activity_second);
        b2 = (Button) findViewById(R.id.b2);
        b2.setOnClickListener(new OnClickListener() {
  
            @Override
            public void onClick(View v) {
                finish();
            }});}}
  </code></pre>
  </blockquote>
  
  <p>//--</p>
  
  <blockquote>
  <pre><code>    &lt;Button
          android:id="@+id/b1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/textView1"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="143dp"
          android:text="Button" /&gt;
  </code></pre>
  </blockquote>
  
  <p>//--</p>
  
  <blockquote>
  <pre><code>&lt;Button
          android:id="@+id/b2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Button" /&gt;
  </code></pre>
  </blockquote>