Q:

How to input text in EditText with 2 groups of RadioButtons

I have 2 groups of radio buttons. And I want to make when btn1stDigitBrown1 of 1st group is pressed it shows on display "1" just as it is in code below and when btn2ndDigitBlack0 from 2nd group is pressed it should also show one number next to the number that was just written on EditText, for example, "10". And when the button of the 2nd group is pressed (for example btn2ndDigitBlack0) before button from 1st group is pressed, it should automatically show on EditText "10". For now, when RadioButton from the 2nd group is pressed it rewrites number written already on EditText. This is my code:
    View.OnClickListener listener1stDigit = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.btn1stDigitBrown1:
                    ((EditText)findViewById(R.id.resistText)).setText("1");
                    break;
                case R.id.btn1stDigitRed2:
                    ((EditText)findViewById(R.id.resistText)).setText("2");
                    break;
                case R.id.btn1stDigitOrange3:
                    ((EditText)findViewById(R.id.resistText)).setText("3");
                    break;
                case R.id.btn1stDigitYellow4:
                    ((EditText)findViewById(R.id.resistText)).setText("4");
                    break;
                case R.id.btn1stDigitGreen5:
                    ((EditText)findViewById(R.id.resistText)).setText("5");
                    break;
                case R.id.btn1stDigitBlue6:
                    ((EditText)findViewById(R.id.resistText)).setText("6");
                    break;
                case R.id.btn1stDigitViolet7:
                    ((EditText)findViewById(R.id.resistText)).setText("7");
                    break;
                case R.id.btn1stDigitGrey8:
                    ((EditText)findViewById(R.id.resistText)).setText("8");
                    break;
                case R.id.btn1stDigitWhite9:
                    ((EditText)findViewById(R.id.resistText)).setText("9");
                    break;
                default:
            }
        }
    };

    btn1stDigitBrown1.setOnClickListener(listener1stDigit);
    btn1stDigitRed2.setOnClickListener(listener1stDigit);
    btn1stDigitOrange3.setOnClickListener(listener1stDigit);
    btn1stDigitYellow4.setOnClickListener(listener1stDigit);
    btn1stDigitGreen5.setOnClickListener(listener1stDigit);
    btn1stDigitBlue6.setOnClickListener(listener1stDigit);
    btn1stDigitViolet7.setOnClickListener(listener1stDigit);
    btn1stDigitGrey8.setOnClickListener(listener1stDigit);
    btn1stDigitWhite9.setOnClickListener(listener1stDigit);

    View.OnClickListener listener2ndDigit = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.btn2ndDigitBlack0:
                    ((EditText)findViewById(R.id.resistText)).setText("0");
                    break;
                case R.id.btn2ndDigitBrown1:
                    ((EditText)findViewById(R.id.resistText)).setText("1");
                    break;
                case R.id.btn2ndDigitRed2:
                    ((EditText)findViewById(R.id.resistText)).setText("2");
                    break;
                case R.id.btn2ndDigitOrange3:
                    ((EditText)findViewById(R.id.resistText)).setText("3");
                    break;
                case R.id.btn2ndDigitYellow4:
                    ((EditText)findViewById(R.id.resistText)).setText("4");
                    break;
                case R.id.btn2ndDigitGreen5:
                    ((EditText)findViewById(R.id.resistText)).setText("5");
                    break;
                case R.id.btn2ndDigitBlue6:
                    ((EditText)findViewById(R.id.resistText)).setText("6");
                    break;
                case R.id.btn2ndDigitViolet7:
                    ((EditText)findViewById(R.id.resistText)).setText("7");
                    break;
                case R.id.btn2ndDigitGrey8:
                    ((EditText)findViewById(R.id.resistText)).setText("8");
                    break;
                case R.id.btn2ndDigitWhite9:
                    ((EditText)findViewById(R.id.resistText)).setText("9");
                    break;
                default:
            }
        }
    };

    btn2ndDigitBlack0.setOnClickListener(listener2ndDigit);
    btn2ndtDigitBrown1.setOnClickListener(listener2ndDigit);
    btn2ndDigitRed2.setOnClickListener(listener2ndDigit);
    btn2ndDigitOrange3.setOnClickListener(listener2ndDigit);
    btn2ndDigitYellow4.setOnClickListener(listener2ndDigit);
    btn2ndDigitGreen5.setOnClickListener(listener2ndDigit);
    btn2ndDigitBlue6.setOnClickListener(listener2ndDigit);
    btn2ndDigitViolet7.setOnClickListener(listener2ndDigit);
    btn2ndDigitGrey8.setOnClickListener(listener2ndDigit);
    btn2ndDigitWhite9.setOnClickListener(listener2ndDigit);

A:

I think what you need to do is to learn how to manipulate strings
You should read this
What you should do in the 2nd listener is concatenate the new number
switch (view.getId()) {
     case R.id.btn2ndDigitBlack0: {
         EditText editText = ((EditText)findViewById(R.id.resistText))
         String oldString = editText.getText()
         if (oldString.length <= 1) {
            editText.setText(oldString + "0")
         } else {
             editText.setText(oldString.substring(0, 1) + "0")
         }
         }
     ...

