Android Studio - Button Click Crash (Simple)
<p>I'm brand new to Android Studio and for whatever reason am experiencing really weird errors if I could please get some help.</p>

<p>I have very basic code that is supposed to, on button click change the text of my button from "button" to "clicked!". However everytime I press the button, the app crashes and I get "Appname has stopped" on the emulator.</p>

<p>What is incredibly weird is that in my activity_main.xml Design view, the onClick dropdown shows two functions of the same name (<a href="https://puu.sh/t2h5I/42ad4379d6.png" rel="nofollow noreferrer">https://puu.sh/t2h5I/42ad4379d6.png</a>)</p>

<p>H owever the code only works when the bottom one is selected. AND each time I run the app, it deselects the bottom one and reselects the top, only to stop working. </p>

<p>Here is my MainActivity:</p>

<pre><code>package com.example.john.ameladay;


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    public Button melButtonCode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void buttonPress(View v){
        melButtonCode = (Button) v;
        ((Button) v).setText("Has been clicked!");

    }
}
</code></pre>

<p>Here is my activity_main.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:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
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.example.john.ameladay.MainActivity"&gt;

&lt;TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/mainText"
    android:id="@+id/textView" /&gt;

&lt;ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/mela"
    android:id="@+id/melPhoto" /&gt;

&lt;Button
    android:text="Button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_toRightOf="@+id/textView"
    android:layout_toEndOf="@+id/textView"
    android:layout_marginLeft="32dp"
    android:layout_marginStart="32dp"
    android:layout_marginBottom="43dp"
    android:id="@+id/button"
    android:onClick="buttonPress (MainActivity)" /&gt;
</code></pre>

<p></p>

<p>Any help would be greatly appreciated!!</p>