How do I disable the third and fourth EditText if the first one is not populated?

0

I have three EditText and I need to check if the first EditText is empty and if the second EditText is also empty.

Affirmative case I should disable the third EditText.

How can I do this?

    
asked by anonymous 16.08.2017 / 16:36

1 answer

1

A simple case that could sacionar your problem would be, if clicking on the editText, it does these checks and validations for you

     editText1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String editText1_text = editText1.getText().toString();
            String editText2_text = editText2.getText().toString();

            if(editText1_text == null && editText2_text == null)
                editText3_text.setVisibility(GONE);
            else if(editText1_text != null && editText2_text != null)
                editText3_text.setVisibility(VISIBLE);
        }

    });

editText2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        String editText1_text = editText1.getText().toString();
        String editText2_text = editText2.getText().toString();

        if(editText1_text == null && editText2_text == null)
            editText3_text.setVisibility(GONE);
        else if(editText1_text != null && editText2_text != null)
            editText3_text.setVisibility(VISIBLE);

        }
    });
    
16.08.2017 / 16:46