title: button not working after changing the orientation
body: <p>When I start the application, the button works. Each time I rotate the cellphone, onConfigurationChanged is called. However onClick is no more called after I pressed the button. How can I to fix this? Thanks in advance.</p>
  
  <p>PS: The actual program is a calculator with a lot of buttons.</p>
  
  <pre><code>package com.thomas.test.app;
  
  import android.app.Activity;
  import android.content.res.Configuration;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.Toast;
  
  
  public class MainActivity extends Activity implements View.OnClickListener
  {
      Button button1;
  
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
  
          if (newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE)
              setContentView(R.layout.activity_main_h);
          else if (newConfig.orientation==Configuration.ORIENTATION_PORTRAIT)
              setContentView(R.layout.activity_main_v);
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main_v);
  
          button1 = (Button)findViewById(R.id.button1);
          button1.setOnClickListener(this);
      }
  
      @Override
      public void onClick(View view) {
          Log.d("XYZ", "onClick: IN");
          if (view.getId()==R.id.button1)
              button1.setText("PRESSED");
      }
  }
  </code></pre>
  
  <p>This is the activity_main_h.xml (activity_main_v is identical except for displaying "vertical"):</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.thomas.test.app.MainActivity"&gt;
  
      &lt;TextView
          android:text="horizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/textView" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="New Button"
          android:id="@+id/button1"
          android:layout_below="@+id/textView"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>