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 7823233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:10:30+00:00 2026-06-02T08:10:30+00:00

I always have issues for some reason when trying to set a textviews text

  • 0

I always have issues for some reason when trying to set a textviews text to a number. In the following code I am trying to make a tip calculator, but when I run the app it force closes. The app works perfectly fine when I remove the items in the OnClick listener. I’ll post the logcat after the code. Please tell me anything else that is helpful that I can post to improve the chance of my question getting answered.

billAmount = (EditText) findViewById(R.id.billAmount);
    tipPercent = (EditText) findViewById(R.id.tipPercent);

Those are the editTexts.

    @Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.calculateTip:
        double billAmt = Double.parseDouble(billAmount.toString());
        double tipAmt = Double.parseDouble(tipPercent.toString());
        double billtip = (billAmt * tipAmt) / 100;
        totalTip.setText("" + Double.toString(billtip));
        break;
    }
}

Here’s the logcat

04-22 01:20:20.104: W/KeyCharacterMap(589): No keyboard for id 0
04-22 01:20:20.104: W/KeyCharacterMap(589): Using default keymap:           /system/usr/keychars/qwerty.kcm.bin
04-22 01:20:24.174: D/AndroidRuntime(589): Shutting down VM
04-22 01:20:24.174: W/dalvikvm(589): threadid=1: thread exiting with uncaught exception     (group=0x4001d800)
04-22 01:20:24.195: E/AndroidRuntime(589): FATAL EXCEPTION: main
04-22 01:20:24.195: E/AndroidRuntime(589): java.lang.NumberFormatException:     android.widget.EditText@44f54a78
04-22 01:20:24.195: E/AndroidRuntime(589):  at     org.apache.harmony.luni.util.FloatingPointParser.initialParse(FloatingPointParser.java:130)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:281)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     java.lang.Double.parseDouble(Double.java:287)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     com.tool.TipCalculator.onClick(TipCalculator.java:38)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     android.view.View.performClick(View.java:2408)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     android.view.View$PerformClick.run(View.java:8816)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     android.os.Handler.handleCallback(Handler.java:587)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     android.os.Handler.dispatchMessage(Handler.java:92)
04-22 01:20:24.195: E/AndroidRuntime(589):  at android.os.Looper.loop(Looper.java:123)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     android.app.ActivityThread.main(ActivityThread.java:4627)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     java.lang.reflect.Method.invokeNative(Native Method)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     java.lang.reflect.Method.invoke(Method.java:521)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-22 01:20:24.195: E/AndroidRuntime(589):  at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-22 01:20:24.195: E/AndroidRuntime(589):  at dalvik.system.NativeStart.main(Native     Method)

I’m fairly sure I have solved the problem. just doing

Double.parseDouble(editText.toString();

Doesn’t work. I needed to add in

Double.parseDouble(editText.getText().toString();
  • 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-02T08:10:36+00:00Added an answer on June 2, 2026 at 8:10 am

    Use billAmount.getText().toString(); instead of billAmount.toString();

    and the same for tipPercent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been trying to figure this out but i just can't.... for some
I'm trying to make sense of a situation I have using entity framework on
I'm new to javascript and was trying to refactor some code, clearly there's something
in our system we store orders. We always have customer specific code in our
I always have trouble designing the user interface when it come to manage a
I always have trouble with complicated SQL queries. This is what I have $query
I have a winforms datagridview that seems to always have at least one row
I almost always have a Scala REPL session or two open, which makes it
as the comments always have it, you can select to show the top 5
All tables in my database always have an id (autoincrement), at column 0 regardless

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.