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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:37:19+00:00 2026-05-27T18:37:19+00:00

i have 1 edittext with number input only.the problem is,suppose user types 1234 no

  • 0

i have 1 edittext with number input only.the problem is,suppose user types 1234 no in it and afterwrds if he wants to change it and for that when he wil press del key tat time wen he cmes at 2 and press one more time del key,application crashes.and i tried handling if edittext text length 0 case also but stil not wrkng
here is my code

 input.addTextChangedListener(new TextWatcher() {            
        public void onTextChanged(CharSequence s, int start, 
                                 int before, int count) 
        {
            final String in= input.getText().toString();//input is edittext
            final int j=in.length(); 
            Cursor ansof1=(Cursor) mSpinner.getSelectedItem();//1st spinner tks 1 value
            String temp=ansof1.getString(1);

            Cursor ansof2=(Cursor)mSpinner2.getSelectedItem();//for 2 spinner
            String temp2=ansof2.getString(1);
            Cursor cn = myDbHelper.selectcur(temp);
             double ans1=cn.getDouble(3);   
            Cursor cm=myDbHelper.selectcur(temp2);
            double ans2=cm.getDouble(3);
            no = Integer.parseInt(in);

        final double finalans=((ans1/ans2)*no);
        NumberFormat formatter = new DecimalFormat("##,##,###");
    if(temp.equalsIgnoreCase(temp2))
        {

            //dlgAlert.setMessage("OOpss..!! Both Currencies Are Same...!!");
            text1.setText(no+" "+temp+" "+"="+" "+no+" "+temp2);

            //dlgAlert.create().show();

        }
        else

        text1.setText(no+" "+temp+" "+"="+" "+formatter.format(finalans)+" "+temp2);


        }

        @Override
        public void afterTextChanged(Editable arg0) 
        {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after)
        {
            // TODO Auto-generated method stub

        }
    });
  • 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-05-27T18:37:20+00:00Added an answer on May 27, 2026 at 6:37 pm

    It’s because you try to convert empty string to number. So check for length of string like this,

    input.addTextChangedListener(new TextWatcher() {             
            public void onTextChanged(CharSequence s, int start,  
                                     int before, int count)  
            { 
               if(s.length()==0)
               {
                     return;
               }
               else
               {
                      // your code here
               }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 14 edittext boxes that a user can change at will. When the
I have an activity that contains several user editable items (an EditText field, RatingBar,
So I have a simple Edit-text with number input. User enters his phone number
I have an editText that brings up the number keyboard. When you enter a
in my app i have three editText where the user can place a number.then.when
I have an activity with one EditText where I need to input numbers only.
I want an editText that only allows text input from A to z ,
i have two edit text one edit text input should accept number only so
To use as an example: lets say that I have 2 EditText s and
I have a UI that has 6 EditText boxes. 3 of those EditText boxes

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.