title: How to 'link' an activity to a java class in Android Studio
body: <p>So, I'm trying to wrap my head around Android Studio, but I find something very confusing. When you make a new activity it also makes a Java class, yet coding anything into that java class doesn't seem to do anything. Yet coding something into the MainActivity does.</p>
  
  <p>Example names</p>
  
  <p>MainActivity
  SecondActivity
  main_activity
  second_activity</p>
  
  <p>Adding an onClick event for a (Button for example) in second_activity, it checks the MainActivity class for the pubic void onClickName(){ } rather than the SecondActivity class. Is there something somewhere that I have to change?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  &lt;EditText
      android:layout_width="match_parent"
      android:layout_height="40dp"
      android:text=""
      android:hint="Player name here"
      android:layout_alignParentTop="true"
      android:id="@+id/txtName"
      android:layout_toStartOf="@+id/btnAddPlayer" /&gt;
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Back to Main menu"
      android:id="@+id/button"
      android:layout_alignParentBottom="true"
      android:layout_alignParentStart="true"
      android:onClick="backToMain"/&gt;
  
  &lt;ListView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/spnCharacters"
      android:layout_below="@+id/txtName"
      android:layout_marginTop="56dp"
      android:layout_alignParentEnd="true"
      android:background="@drawable/bg_key"/&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Add Player"
      android:id="@+id/btnAddPlayer"
      android:layout_alignBottom="@+id/txtName"
      android:layout_alignParentEnd="true"
      android:onClick="addPlayer"/&gt;
  </code></pre>
  
  <p>
  Yet neither addPlayer nor backToMain in SecondActivity does nothing, yet if in MainActivity they do whatever I've coded in</p>
  
  <p>SecondActivity onCreate</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.second_activity);
  }
  </code></pre>