I'm making an android program and it's failing due to a stackoverflow error. I have attached my code. I'm using android studio. I believe that it's looping because of addTextChangedListener but I can't understand why it's doing it.
My Code:
    rb1 = (RadioButton) findViewById(R.id.radioButtonCFM);
    rb2 = (RadioButton) findViewById(R.id.radioButtonAC);
    rb1.setOnClickListener(new RadioGroup.OnClickListener() {
         public void onClick(View v) {
             EditText e1 = (EditText) findViewById(R.id.editText);
             String sUsername1 = e1.getText().toString();
             if (TextUtils.isEmpty(sUsername1)) {
                 e1.setError("The item cannot be empty.");
                 return;
             }
             EditText e2 = (EditText) findViewById(R.id.editText2);
             String sUsername2 = e2.getText().toString();
             if (TextUtils.isEmpty(sUsername2)) {
                 e2.setError("The item cannot be empty.");
                 return;
             }
             EditText e3 = (EditText) findViewById(R.id.editText3);
             String sUsername3 = e3.getText().toString();
             if (TextUtils.isEmpty(sUsername3)) {
                 e3.setError("The item cannot be empty.");
                 return;
             }
             e1.addTextChangedListener(new TextWatcher() {
                 public void afterTextChanged(Editable s) {
                 }
                 public void beforeTextChanged(CharSequence s, int start,
                                               int count, int after) {
                 }
                 public void onTextChanged(CharSequence s, int start,
                                           int before, int count) {
                     EditText e1 = (EditText)findViewById(R.id.editText);
                     EditText e2 = (EditText)findViewById(R.id.editText2);
                     EditText e3 = (EditText)findViewById(R.id.editText3);
                     volume = Double.parseDouble(e1.getText().toString());
                     cfm = Double.parseDouble(e2.getText().toString());
                     ac = Double.parseDouble(e3.getText().toString());
                     TextView t1 = (TextView) findViewById(R.id.editText3);
                     volume = Double.parseDouble(e1.getText().toString());
                     cfm = Double.parseDouble(e2.getText().toString());
                     ac = cfm * 60 / volume;
                     t1.setText(Double.toString((double) Math.round(ac * 100000) / 100000));
                 }
             });
             e2.addTextChangedListener(new TextWatcher() {
                 public void afterTextChanged(Editable s) {
                 }
                 public void beforeTextChanged(CharSequence s, int start,
                                               int count, int after) {
                 }
                 public void onTextChanged(CharSequence s, int start,
                                           int before, int count) {
                     EditText e1 = (EditText)findViewById(R.id.editText);
                     EditText e2 = (EditText)findViewById(R.id.editText2);
                     EditText e3 = (EditText)findViewById(R.id.editText3);
                     volume = Double.parseDouble(e1.getText().toString());
                     cfm = Double.parseDouble(e2.getText().toString());
                     ac = Double.parseDouble(e3.getText().toString());
                     TextView t1 = (TextView) findViewById(R.id.editText3);
                     volume = Double.parseDouble(e1.getText().toString());
                     cfm = Double.parseDouble(e2.getText().toString());
                     ac = cfm * 60 / volume;
                     t1.setText(Double.toString((double) Math.round(ac * 100000) / 100000));
                 }
             });
         }});
     rb2.setOnClickListener(new RadioGroup.OnClickListener() {
         public void onClick(View v) {
             EditText e1 = (EditText)findViewById(R.id.editText);
             String sUsername1 = e1.getText().toString();
             if(TextUtils.isEmpty(sUsername1)) {
                 e1.setError("The item cannot be empty.");
                 return;
             }
             EditText e2 = (EditText)findViewById(R.id.editText2);
             String sUsername2 = e2.getText().toString();
             if(TextUtils.isEmpty(sUsername2)) {
                 e2.setError("The item cannot be empty.");
                 return;
             }
             EditText e3 = (EditText)findViewById(R.id.editText3);
             String sUsername3 = e3.getText().toString();
             if(TextUtils.isEmpty(sUsername3)) {
                 e3.setError("The item cannot be empty.");
                 return;
             }
             e1.addTextChangedListener(new TextWatcher() {
                 public void afterTextChanged(Editable s) {
                 }
                 public void beforeTextChanged(CharSequence s, int start,
                                               int count, int after) {
                 }
                 public void onTextChanged(CharSequence s, int start,
                                           int before, int count) {
                     EditText e1 = (EditText)findViewById(R.id.editText);
                     EditText e2 = (EditText)findViewById(R.id.editText2);
                     EditText e3 = (EditText)findViewById(R.id.editText3);
                     volume = Double.parseDouble(e1.getText().toString());
                     cfm = Double.parseDouble(e2.getText().toString());
                     ac = Double.parseDouble(e3.getText().toString());
                     TextView t2 = (TextView)findViewById(R.id.editText2);
                     volume = Double.parseDouble(e1.getText().toString());
                     ac = Double.parseDouble(e3.getText().toString());
                     cfm = ac * volume / 60;
                     t2.setText(Double.toString((double) Math.round(cfm * 100000) / 100000));
                 }
             });
             e3.addTextChangedListener(new TextWatcher() {
                 public void afterTextChanged(Editable s) {
                 }
                 public void beforeTextChanged(CharSequence s, int start,
                                               int count, int after) {
                 }
                 public void onTextChanged(CharSequence s, int start,
                                           int before, int count) {
                     EditText e1 = (EditText)findViewById(R.id.editText);
                     EditText e2 = (EditText)findViewById(R.id.editText2);
                     EditText e3 = (EditText)findViewById(R.id.editText3);
                     volume = Double.parseDouble(e1.getText().toString());
                     cfm = Double.parseDouble(e2.getText().toString());
                     ac = Double.parseDouble(e3.getText().toString());
                     TextView t2 = (TextView)findViewById(R.id.editText2);
                     volume = Double.parseDouble(e1.getText().toString());
                     ac = Double.parseDouble(e3.getText().toString());
                     cfm = ac * volume / 60;
                     t2.setText(Double.toString((double) Math.round(cfm * 100000) / 100000));
                 }
             });
         }
     });
     }
 
     
     
     
     
    