title: Android Studio - image button is crashing after i click on it
body: <p>I am trying to make some simple image click button to go to another activity but I can't get it to work.</p>
  
  <p>It says: </p>
  
  <pre><code>Unfortunately, myapp has stopped.
  </code></pre>
  
  <p>If I highlighted my android: <code>onClick="myButton"</code> it says <code>Method myButton' is missing in 'MainActivity' in my layout.xml</code></p>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.zemoapps.alarmclockgold;
  
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Typeface;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  
  //Old code "public class MainActivity extends AppCompatActivity {"
  public class MainActivity extends AppCompatActivity {
  
      private Button myButton;
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
  
          TextView myTextview = (TextView) findViewById(R.id.RepeatingText);
          TextView myTextview2 = (TextView) findViewById(R.id.CountDownText);
          Typeface myCustomFont = Typeface.createFromAsset(getAssets(), "fonts/AndadaRegular.otf");
          myTextview.setTypeface(myCustomFont);
          myTextview2.setTypeface(myCustomFont);
  
  
      }
  
      public class MyCustomTextView extends TextView {
  
          public MyCustomTextView(Context context, AttributeSet attrs) {
              super(context, attrs);
              this.setTypeface(Typeface.createFromAsset(context.getAssets(),
                      "fonts/AndadaRegular.otf"));
          }
  
      }
  
      public class AlarmPage extends AppCompatActivity {
  
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
              myButton = (Button) findViewById(R.id.RepeatingImage);
  
              myButton.setOnClickListener(new View.OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
  
                      startActivity(new Intent(MainActivity.this, AddAlarm.class));
  
                  }
              });
  
  
          }
  
  
      }}
  </code></pre>
  
  <p>Layout.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:andriod="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/BG"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#9e84d3"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.zemoapps.onething.MainActivity"&gt;
  
  &lt;ImageButton
      android:id="@+id/RepeatingImage"
      android:layout_width="200dp"
      android:layout_height="150dp"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:background="#00000000"
      android:contentDescription="@null"
      android:onClick="myButton"
      android:scaleType="fitCenter"
      android:src="@drawable/alarm1" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><code>AndroidManifest</code> says there is error too:
  <a href="https://i.stack.imgur.com/ZfJS6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZfJS6.png" alt="enter image description here"></a></p>
  
  <pre><code>java.lang.IllegalStateException: Could not find method myButton(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatImageButton with id 'RepeatingImage'
                                                                                   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:307)
                                                                                   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:266)
                                                                                   at android.view.View.performClick(View.java:4084)
                                                                                   at android.view.View$PerformClick.run(View.java:16966)
                                                                                   at android.os.Handler.handleCallback(Handler.java:615)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                                   at android.os.Looper.loop(Looper.java:137)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                                   at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                   at java.lang.reflect.Method.invoke(Method.java:511)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                                   at dalvik.system.NativeStart.main(Native Method)
  </code></pre>