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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:58:50+00:00 2026-06-04T07:58:50+00:00

I have been trying to accept two values, 1) inpval2 and 2) rate, through

  • 0

I have been trying to accept two values, 1) inpval2 and 2) rate, through EditText. I have used the Integer class and parseInt() method along with

android:digits="0123456789."
android:inputType="number"

attributes to convert accepted values as integers.

Here is the code:

package kk.currency;

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

public class CurrencyActivity extends Activity {
/** Called when the activity is first created. */

EditText inpval1;
EditText inpval2;
EditText rate;

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

public void btnclick(View view)  {

        inpval1 = (EditText)findViewById(R.id.away);
        int v1 = Integer.parseInt(inpval1.getText().toString());

        inpval2 = (EditText)findViewById(R.id.home);
        int v2 = Integer.parseInt(inpval2.getText().toString());

        rate = (EditText)findViewById(R.id.rate);
        int r = Integer.parseInt(rate.getText().toString());  

        v1 = v2 * r;

    }

}

Now the problem is that when I click the button (onClick = “btnclick”) the app stops working.

If I remove

int v1 = Integer.parseInt(inpval1.getText().toString());
int v2 = Integer.parseInt(inpval2.getText().toString());
int r = Integer.parseInt(rate.getText().toString());

the app does not crash upon the click of the button.

Here are the logcat errors:

> 05-17 02:59:04.676: D/gralloc_goldfish(869): Emulator without GPU emulation detected.
05-17 02:59:13.907: D/AndroidRuntime(869): Shutting down VM
05-17 02:59:13.907: W/dalvikvm(869): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
05-17 02:59:13.946: E/AndroidRuntime(869): FATAL EXCEPTION: main
05-17 02:59:13.946: E/AndroidRuntime(869): java.lang.IllegalStateException: Could not execute method of the activity
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.view.View$1.onClick(View.java:3044)
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.view.View.performClick(View.java:3511)
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.view.View$PerformClick.run(View.java:14105)
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.os.Handler.handleCallback(Handler.java:605)
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.os.Looper.loop(Looper.java:137)
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.app.ActivityThread.main(ActivityThread.java:4424)
05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.reflect.Method.invokeNative(Native Method)
05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.reflect.Method.invoke(Method.java:511)
05-17 02:59:13.946: E/AndroidRuntime(869):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-17 02:59:13.946: E/AndroidRuntime(869):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-17 02:59:13.946: E/AndroidRuntime(869):  at dalvik.system.NativeStart.main(Native Method)
05-17 02:59:13.946: E/AndroidRuntime(869): Caused by: java.lang.reflect.InvocationTargetException
05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.reflect.Method.invokeNative(Native Method)
05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.reflect.Method.invoke(Method.java:511)
05-17 02:59:13.946: E/AndroidRuntime(869):  at android.view.View$1.onClick(View.java:3039)
05-17 02:59:13.946: E/AndroidRuntime(869):  ... 11 more
05-17 02:59:13.946: E/AndroidRuntime(869): Caused by: java.lang.NumberFormatException: Invalid int: ""
05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.Integer.invalidInt(Integer.java:138)
05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.Integer.parseInt(Integer.java:359)
05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.Integer.parseInt(Integer.java:332)
05-17 02:59:13.946: E/AndroidRuntime(869):  at kk.currency.CurrencyActivity.btnclick(CurrencyActivity.java:24)
05-17 02:59:13.946: E/AndroidRuntime(869):  ... 14 more

Can anyone please help me with this? I’m a beginner and have spent quite a lot of time on this to try find a solution.

  • 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-04T07:58:51+00:00Added an answer on June 4, 2026 at 7:58 am

    Here’s your problem:

    05-17 02:59:13.946: E/AndroidRuntime(869): Caused by: java.lang.NumberFormatException: Invalid int: "" 
    05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.Integer.invalidInt(Integer.java:138) 
    05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.Integer.parseInt(Integer.java:359) 
    05-17 02:59:13.946: E/AndroidRuntime(869):  at java.lang.Integer.parseInt(Integer.java:332) 
    05-17 02:59:13.946: E/AndroidRuntime(869):  at kk.currency.CurrencyActivity.btnclick(CurrencyActivity.java:24) 
    05-17 02:59:13.946: E/AndroidRuntime(869):  ... 14 more 
    

    The line at kk.currency.CurrencyActivity.btnclick(CurrencyActivity.java:24) tells you that in your CurrencyActivity.java file, on line 24, it’s throwing a NumberFormatException because of an invalid int, which is the empty String “”. This means you’re clicking with one of your fields empty, and it’s trying to parse “” as an integer and throwing an exception when it fails.

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

Sidebar

Related Questions

Have have been trying to make a validator for my xml files. I have
I have been trying this for the whole day and I managed to make
I have been trying to get a response from a server sending a GET
I have been trying real hard understanding regular expression, Is there any way I
I have been trying to figure out the following excerpt from Ruby on Rails
I have been trying to access an HTTPS URL with the HTMLUnitDriver API of
I have been trying this for a while but thus far haven't had any
I have been trying to create a Main program that calls another program, sending
I have been trying to pull out my SQLite database from my android application
I have been trying to make something like Facebook @tagged Friend name add in

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.