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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:10:25+00:00 2026-06-18T19:10:25+00:00

I have two EditText boxes and a RadioGroup which contains two radio buttons. When

  • 0

I have two EditText boxes and a RadioGroup which contains two radio buttons. When I start entering input in any of edittext boxes, All the radiobuttons has to be checked off (if any one of buttons has checked already) automatically and another edittext also should be cleared. And If i check any of two radio buttons then all edittext boxes should be cleared(if they have any inputted data). Here is what i have done so far.

Inside oncreate() :

    et1 = (EditText)findViewById(R.id.editText1);
    et1.setOnFocusChangeListener(this);
    et1.addTextChangedListener(this);

    et2 = (EditText)findViewById(R.id.editText2);
    et2.setOnFocusChangeListener(this);
    et2.addTextChangedListener(this); 

    radioButton1 = (RadioButton)findViewById(R.id.rb1);
    radioButton2 = (RadioButton)findViewById(R.id.rb2);
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup);        
    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener(){
        public void onCheckedChanged(RadioGroup group, int checkedId) {

             et1.setText("");
            et2.setText("");

        }

    });

And …

 @Override
public void onFocusChange(View v, boolean hasFocus) {

    switch (v.getId()) {
    case R.id.editText1:
        whoHasFocus = 1;

        break;
    case R.id.editText2 :
        whoHasFocus = 2;

        break;

    }

}

And

   @Override
public void afterTextChanged(Editable edt) {

    if(whoHasFocus == 1){
        String enteredName1 = edt.toString().trim();

        if(enteredName1.length() == 1){
            if(et2.getText().toString().trim().length() >= 1)
                et2.setText("");

            radioButton1.setChecked(false);
            radioButton2.setChecked(false);

        } 

    }else if(whoHasFocus == 2){

        String enteredName2 = edt.toString().trim();
        if(enteredName2.length() == 1){
            if(et1.getText().toString().trim().length() >= 1)
                et1.setText("");

            radioButton1.setChecked(false);
            radioButton2.setChecked(false);
        } 
    }
}

When i check any radio button and start typing in edittext, radiobutton is getting unchecked but nothing is entering into edittext for the first time. If i enter next letter then it is entering the second letter and working fine then onwards. But First letter is not being entered into endittext when a radiobutton is checked. please help me. Where iam going wrong?

  • 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-18T19:10:27+00:00Added an answer on June 18, 2026 at 7:10 pm

    Solved

                radioGroup.setOnCheckedChangeListener(null);
                radioButton1.setChecked(false);
                radioButton2.setChecked(false);
                radioGroup.setOnCheckedChangeListener(this);
    

    And

        et1.removeTextChangedListener(MyActivity.this);
        et2.removeTextChangedListener(MyActivity.this);
        et1.setText(""); 
        et2.setText("");
        et1.addTextChangedListener(MyActivity.this);
        et2.addTextChangedListener(MyActivity.this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two EditText boxes editText1 and editText2 and I'm trying to give input
i am self_learner to android. I have two screens.The first screen contains one edittext
I have a custom dialog with one editText view and two buttons ok and
I have two edittext input box. First one is for username and the second
Hi i have Two radio button(subject and chapter) and two edittext(SubjectName,ChapterName). My question is
I have two EditText's. One with start date and other with end date. I
I have two LinearLayout One contains a EditText with a patch9 image as a
I have an activity that has two EditText boxes, one email and one plain
I have a simple login layout that contains two EditText fields and a Button
Hi i have a login form which has two EditText's one for email one

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.