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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:38:50+00:00 2026-06-11T03:38:50+00:00

I have created edittexts in which user can enter numbers. In my app user

  • 0

I have created edittexts in which user can enter numbers. In my app user can submit the values by clicking on submit button.(Note: Initially I set all 3 EditTexts to “” with setText() in the code)After submitting I have kept these following lines to retrieve values in the method.

String st1=editText1.getText().toString();
int tempVal1=Integer.parseInt(st);
String st2=editText2.getText().toString();
int tempVa2=Integer.parseInt(st);
String st3=editText2.getText().toString();
int tempVal3=Integer.parseInt(st);

But here my problem is if the user doesn’t enter any value in the first editText and fills only 2nd and 3rd and submits, then the value in the tempVal1 should be 0. But I am getting exception becuase of the first statement because of not having any data. How to avoid this exception and keep the tempVal 0 when he doesn’t fill anything in the respective edittext?

I have one more doubt, when I add this int x=Integer.valueOf(editText.getText()); line, I am getting the following error. Why?The method valueOf(String) in the type Integer is not applicable for the arguments (Editable)

Please clarify my doubts.

  • 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-11T03:38:51+00:00Added an answer on June 11, 2026 at 3:38 am

    You need to check the EditText before converting it into Number.

    if( !editText1.getText().toString().equals("") && editText1.getText().toString().length() > 0 )
    {
        // Get String
        Integer.parseInt(editText1.getText().toString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey i'm trying to build an app in which the user can input some
I have a form which renders, but when I click the submit button, I
Hi I have created 6x6 edittexts (which cover 70% of the screen)in my application
I am writing a simple android app which have a edittext and a button.
I have created a Spinner and have populated it with values for my app
I have the following class which as you can see contains a EditText, Button
I have a listview that contain several EditTexts created dynamically according to the number
I have this textbox in the other activity and a button which leads to
I have an edittext which is created programmatically (so not in xml) and I
I have three activities where the first activity is the welcome app page(SavingsGuiderSplashActivity) which

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.