title: Use back button to go to main view
body: <p>I have an app with a main view and a set of sub-views, defined as XMLs.
  I load the main view with:</p>
  
  <pre><code>@Override
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  </code></pre>
  
  <p>When I switch to another view I do:</p>
  
  <pre><code>holaPlayerBtn.setOnClickListener(new OnClickListener(){
  @Override
  
  public void onClick(View view)
  {   
      setContentView(R.layout.primerareceta);
      };
  </code></pre>
  
  <p>To go back to the main view I am trying:</p>
  
  <pre><code>@Override
  
  public boolean onKeyDown(int keyCode, KeyEvent event){
      if (keyCode == KeyEvent.KEYCODE_BACK){
          setContentView(R.layout.main);
          return true;
      }
      return super.onKeyDown(keyCode, event);
  }
  </code></pre>
  
  <p>But doing this, what I get is the main view repainted, but the buttons that it contains are not functioning any longer.</p>
  
  <p>Do you know why is happening this?
  How can I go back to the main view with all its button functioning as in the previous time?</p>
  
  <p>Thanks for your help
  Pedro</p>