title: How to connect xml with a class on android
body: <p>I have created a new .xml file named &quot;new_game.xml&quot; and a class named &quot;New_Game.java&quot;
  <em><strong>These are not Main activity</strong></em></p>
  <p>new_game.xml:</p>
  <pre><code>&lt;RelativeLayout 
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;              
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;                 
      android:layout_width=&quot;match_parent&quot;               
      android:layout_height=&quot;match_parent&quot;/&gt;               
                
      &lt;Button android:layout_width=&quot;wrap_content&quot;                  
          android:layout_height=&quot;wrap_content&quot;               
          android:text=&quot;Click&quot;                 
          android:id=&quot;@+id/button&quot;              
          android:layout_marginTop=&quot;27dp&quot;                
          android:layout_alignRight=&quot;@+id/editText&quot;/&gt;              
                  
      &lt;EditText android:layout_width=&quot;wrap_content&quot;                 
          android:layout_height=&quot;wrap_content&quot;                
          android:inputType=&quot;textPersonName&quot;                
          android:ems=&quot;10&quot;                
          android:id=&quot;@+id/editText&quot;               
          android:layout_marginTop=&quot;16dp&quot;               
          android:layout_below=&quot;@+id/button&quot;             
          android:layout_marginLeft=&quot;11dp&quot;/&gt;         
         
      &lt;ImageView android:layout_width=&quot;wrap_content&quot;       
          android:layout_height=&quot;wrap_content&quot;       
          android:id=&quot;@+id/imageView&quot;       
          android:paddingTop=&quot;50dp&quot;      
          android:paddingBottom=&quot;50dp&quot;      
          android:paddingLeft=&quot;50dp&quot;      
          android:paddingRight=&quot;50dp&quot;      
          android:background=&quot;@drawable/ic_launcher&quot;       
          android:layout_centerVertical=&quot;true&quot;       
          android:layout_toLeftOf=&quot;@+id/button&quot;/&gt;      
  &lt;/RelativeLayout&gt;  
  </code></pre>
  <p>New_Game.java:</p>
  <pre><code>package com.example.logosquiz;        
  
  import android.app.Activity;        
  import android.app.ListActivity;       
  import android.app.TabActivity;         
  import android.os.Bundle;        
  import android.view.LayoutInflater;           
  import android.view.View;      
  import android.widget.Button;      
  import android.widget.EditText;      
  import android.widget.ImageView;      
  import android.widget.RelativeLayout;    
  
  public class New_Game extends Activity {     
       
      protected void onCreate(Bundle savedInstanceState) {      
          super.onCreate(savedInstanceState);      
          setContentView(R.layout.new_game);      
          Button button1 = (Button)findViewById(R.id.button);        
          final EditText editText1 = (EditText)findViewById(R.id.editText);     
  
          ImageView imageView1 = (ImageView)findViewById(R.id.imageView);
  
          button1.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  editText1.setText(&quot;Hello Android&quot;);     
              }     
          });      
      }
  </code></pre>
  <p>Please explain it very well</p>
  <p>I put on AndroidManifest.xml this</p>
  <blockquote>
  <pre><code>&lt;activity android:name=&quot;.New_Game&quot;&gt; /activity&gt;
  </code></pre>
  </blockquote>
  <p>and this on the event onClick</p>
  <blockquote>
  <p>Intent myIntent = new Intent(v.getContext(), New_Game.class);</p>
  <p>startActivityForResult(myIntent, 0);</p>
  </blockquote>