Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:49:32+00:00 2026-06-09T11:49:32+00:00

Below is the Java file that I used. All of the code works really

  • 0

Below is the Java file that I used. All of the code works really well, but the error above still lingers. Can anyone see the problem?

package tip.calculator;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class TipCalculator extends Activity 
{
    private Button enter;
    EditText myEditField;
    EditText myEditField2;
    float percentage = 0;
    float percentageInp = 0;
    float billAmount = 0;
    double output = 0; 
    String output1 = "";
    Button clearButton ;
    TextView textView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        myEditField = (EditText) findViewById(R.id.percentText);
        enter = (Button)findViewById(R.id.button1);
        myEditField2 = (EditText) findViewById(R.id.billText);
        clearButton = (Button) findViewById(R.id.clearButton);

        enter.setOnClickListener( new OnClickListener() {
            public void onClick(View v) {
                TextView errors;
                textView = (TextView) findViewById(R.id.textView1);
                errors = (TextView) findViewById(R.id.textView4); 
                int a = 0;
                if(myEditField2.getText().toString().equals("")) {
                    errors.setText("Error");
                } else {
                    a++;
                }

                if(myEditField.getText().toString().equals("")){
                    errors.setText("Error");
                } else {
                    a++;
                }

                if(a == 2) {
                    percentageInp = Float.parseFloat(myEditField.getText().toString());
                    billAmount = Float.parseFloat(myEditField2.getText().toString());
                    percentage = ((float)percentageInp /100);

                    output = (double)(billAmount * percentage);

                    double result = output * 100;
                    result = Math.round(result);
                    result = result / 100;

                    output1 = Double.toString(result);

                    View.setText(output1 + " $");
                    errors.setText("");
                }
            }
        });

        clearButton.setOnClickListener( new OnClickListener() {
            public void onClick(View v) {
                TextView errors;
                textView = (TextView) findViewById(R.id.textView1);
                errors = (TextView) findViewById(R.id.textView4); 
                int a = 0;

                if (myEditField2.getText().toString().equals("")) {
                    myEditField.setText("");
                    percentage = 0;
                    percentageInp = 0;
                    billAmount = 0;
                    output = 0; 
                    textView.setText("");
                    output1 = "";
                } else {
                    a++;
                }

                if(myEditField.getText().toString().equals("")) {
                    myEditField2.setText("");
                    percentage = 0;
                    percentageInp = 0;
                    billAmount = 0;
                    output = 0; 
                    output1 = "";
                    textView.setText("");
                 } else {
                    a++;
                 }

                 if (a == 2) {
                    myEditField.setText("");
                    myEditField2.setText("");
                    percentage = 0;
                    percentageInp = 0;
                    billAmount = 0;
                    output = 0; 
                    output1 = "";

                    textView.setText("");
                    errors.setText("");
                }
            }
        });
    }
}

Here is the logcat, where I get an error I don’t understand at all. I never call the method onEnterClick()?

08-02 21:17:37.205: E/AndroidRuntime(27185): FATAL EXCEPTION: main
08-02 21:17:37.205: E/AndroidRuntime(27185): java.lang.IllegalStateException: Could not find a method onEnterClick(View) in the activity class tip.calculator.TipCalculator for onClick handler on view class android.widget.RelativeLayout with id 'errorText'
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.view.View$1.onClick(View.java:3085)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.view.View.performClick(View.java:3620)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.view.View$PerformClick.run(View.java:14292)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.os.Handler.handleCallback(Handler.java:605)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.os.Handler.dispatchMessage(Handler.java:92)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.os.Looper.loop(Looper.java:137)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.app.ActivityThread.main(ActivityThread.java:4507)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at java.lang.reflect.Method.invokeNative(Native Method)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at java.lang.reflect.Method.invoke(Method.java:511)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at dalvik.system.NativeStart.main(Native Method)
08-02 21:17:37.205: E/AndroidRuntime(27185): Caused by: java.lang.NoSuchMethodException: onEnterClick [class android.view.View]
08-02 21:17:37.205: E/AndroidRuntime(27185):    at java.lang.Class.getConstructorOrMethod(Class.java:460)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at java.lang.Class.getMethod(Class.java:915)
08-02 21:17:37.205: E/AndroidRuntime(27185):    at android.view.View$1.onClick(View.java:3078)
08-02 21:17:37.205: E/AndroidRuntime(27185):    ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:49:34+00:00Added an answer on June 9, 2026 at 11:49 am

    I think you have defined the onclick method in the XML Layout also. And you have written the onclick listener in the program. Remove the following line from your xml layout and your program works fine:

    android:onclick="onEnterClick"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following java code, which is giving the error below: import java.io.File;
I'm trying to open a ZIP file in JAVA. The code below works fine
I have a java file Test.java (below) which uses Guava's HashMultiMap (downloaded from http://code.google.com/p/guava-libraries/
im trying to extract some files from a jar-file downloaded using java-webstart. below code
The code below describes a Java situation. I used some psudocode in the getRuntime().exec
I have used the code below to run cmd commands from java (code adopted
I'm having a problem de-compressing a ZIP file using Java. The method is below.
I have the below java code: List<SomePojo> list = new ArrayList<SomePojo>(); //add 100 SomePojo
I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList {
I have written a MapReduce program, code is below: import java.io.IOException; import java.util.Iterator; import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.