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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:31:22+00:00 2026-05-26T04:31:22+00:00

In My Application there is two EditText and one TextView. I have set the

  • 0

In My Application there is two EditText and one TextView.
I have set the Two Textwatcher on that both EditText. Based on the Value in that EditText, The Value of another EditText is changed and it also apply to textView.
All Goes Nice. But if i put the that Another Edittext as like the value of it to be change based on the Another EditText then it gives me stackOverflow Error.
I dont know Where i am wrong. And I am not able to Put the TextWatcher for both the EditText to change the value with respect to each other.

Please Help me for it.
Thanks.
Code :

 amountText.setText(""); // TextView
    excludedText.setText(""); // EditText
    includedText.setText(""); // EditText


    includedText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

                if(!(includedText.getText().toString().equals("")))
                {
                    double included = Double.parseDouble(includedText.getText().toString());
                    included = roundTwoDecimals(included);
        //          double amountValue = (excluded*15/100);

                    String amt = String.valueOf(roundTwoDecimals(included-(included/1.15)));
                    String excluded = String.valueOf(included/1.15);
                    System.out.println("The Amount is: "+amt);
                    amountText.setText(amt);
                    try{
                        excludedText.setText("");
                        excludedText.setText(excluded); //////// Error Line
                    }
                    catch(Exception e)
                    {
                        e.printStackTrace();
                    }
                }
                else
                {
                    amountText.setText("");
                    excludedText.setText(""); // Error line
                }

        }

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

        }

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

        }
    });

    excludedText.addTextChangedListener(new TextWatcher() 
    {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if(!(excludedText.getText().toString().equals("")))
            {
                double excluded = Double.parseDouble(excludedText.getText().toString());
                excluded = roundTwoDecimals(excluded);

                String amt = String.valueOf(roundTwoDecimals(excluded*0.15));
                String included = String.valueOf(roundTwoDecimals(excluded+(excluded*0.15)));
                System.out.println("The Amount is: "+amt);
                amountText.setText(amt);
                includedText.setText(included);
            }
            else
            {
                amountText.setText("");
                includedText.setText("");
            }

        }

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

        }

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

        }
    });

Here my Logcat is:

10-11 09:47:28.288: ERROR/AndroidRuntime(363): FATAL EXCEPTION: main
10-11 09:47:28.288: ERROR/AndroidRuntime(363): java.lang.StackOverflowError
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at     android.text.DynamicLayout.reflow(DynamicLayout.java:261)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.text.DynamicLayout.<init>(DynamicLayout.java:150)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at  android.widget.TextView.makeNewLayout(TextView.java:4851)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.checkForRelayout(TextView.java:5348)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2688)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$1.onTextChanged(GSTActivity.java:73)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$2.onTextChanged(GSTActivity.java:111)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$1.onTextChanged(GSTActivity.java:73)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$2.onTextChanged(GSTActivity.java:111)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$1.onTextChanged(GSTActivity.java:73)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$2.onTextChanged(GSTActivity.java:111)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$1.onTextChanged(GSTActivity.java:73)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$2.onTextChanged(GSTActivity.java:111)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$1.onTextChanged(GSTActivity.java:73)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2556)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.EditText.setText(EditText.java:75)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2531)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at com.project.TaxCalculator.GSTActivity$2.onTextChanged(GSTActivity.java:111)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextView.setText(TextView.java:2691)
10-11 09:47:28.288: ERROR/AndroidRuntime(363):     at android.widget.TextVie

Please refer this logcat and help me to solve it.
Thanks.

  • 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-26T04:31:23+00:00Added an answer on May 26, 2026 at 4:31 am

    This is a problem of stackoverflow you are going to infinite loop.

    You are updating value of one edittext from second one and vice-verse .

    For example ::

    When you enter character in first edit text it will set text of second edit text and at that time in second edit text you have write a code to set text of first edit text so that you are going to infinite loop.

    EDIT

    et1 = (EditText)findViewById(R.id.et1);
    et2 = (EditText)findViewById(R.id.et2);
    
    OnKeyListener onKeyListener = new OnKeyListener() {
    
                @Override
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    String str = ((EditText)v).getText().toString();
                    if(v == et1) {
                        et2.setText(str);
                    }else {
                        et1.setText(str);
                    }
                    return false;
                }
            };
            et1.setOnKeyListener(onKeyListener);
            et2.setOnKeyListener(onKeyListener);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application there have two Outlet, one is UItextfield and another is UIWebview,
I occur a problem when develop a application on android. There have two image
I have a radgrid controlling access to an application for users. There are two
There are two strings test_name that are compared in a VB script. They have
I have a client-server application, where there two options for the server - standalone
I have a CakePHP 1.3 application connecting to Solr 3.3 search. There are two
I have created a wpf application ,there are two canvas i would like to
In my WPF4 Desktop-based application there is a big block with sidebar menu that
I have an application in which there are two buttons side-by-side at the bottom
In my application there are two class one is InternetActivity which only extends Activity

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.