jordan jordan - 1 year ago 319
Java Question

Android Studio method Never Used

I would Like to know why in Android Studio my calculator app crashes because it could not find my method.

Here is my

public void OnClick(View v) {
Button button = (Button) v;
String str = button.getText().toString();

EditText edit = (EditText) findViewById(;

Here is the preview of my calc, all number buttons are set onClick to go to the OnClick method in my MainActivity. (as you can see to the right of the picture)


Can anyone tell me what i am doing wrong here?
Thank you

Answer Source
public void onCreate(Bundle savedInstanceState) {

    Button button = (Button) findViewById(;
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            EditText edit = (EditText) findViewById(;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download