How do I disable the third and fourth Edittext if the first is not filled in?

Asked

Viewed 89 times

0

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

If Yes I must disable the third Edittext.

How can I do that?

  • Right but to do the check you will click a button ?

  • nay. The guy here said that from the moment you type a character in the first Edittext I can already enable the third Edittext for the guy to write....

  • but it seems that it is more difficult

1 answer

1

A simple case that might satiate your problem would be, in case by clicking on 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);

        }
    });
  • At the touch of Edittext right? I’ll do here never tried this way...

  • This, when playing ediText Voce does the checking, but in this case in specific you will enable the third editText if the two others are different from null =)

  • you work with android too?

  • Yes work with android hehe

  • It’s test didn’t work out...

  • I’ll try with textChanged...

  • tmb is an option =) Textchanged checks every time an operation was performed in Edittext

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.