title: Android: findViewById in a not main.xml file
body: <p>I have two layouts: main.xml and journal.xml
  When I click on a button in the main.xml layout, the journal.xml layout will be opened.</p>
  
  <p>The problem is that i would like to create a back button which will re-open the main.xml layout.
  When I try to do:</p>
  
  <pre><code>ImageButton buttonHome = (ImageButton)findViewById(R.id.image);
  </code></pre>
  
  <p>The image is not found because she is not in my main.xml</p>
  
  <p>Could you please help me.</p>
  
  <p>Thanks</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public class MDPI_1Activity extends Activity 
  {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.journal);
          ImageButton buttonJournal = (ImageButton)findViewById(R.id.imageButton1); //Journal
          ImageButton buttonHome = (ImageButton)findViewById(R.id.image); //Journal
  
  
          buttonJournal.setOnClickListener(new Button.OnClickListener() 
          {
  
              public void onClick(View v) 
              {
  
                  setContentView(R.layout.journal);
              }
          });
  
  
          buttonHome.setOnClickListener(new Button.OnClickListener() 
          {
  
              public void onClick(View v) 
              {
  
                  setContentView(R.layout.main);
              }
          });
  
      }
  
  }
  </code></pre>
  
  <p>The "imageButton1" is in my main.xml file and works good but the "image" is in my second xml file named "journal" and does not exist in the R file.</p>