Disable Button when Edit Text Fields empty

后端 未结 7 540
栀梦
栀梦 2020-12-31 04:22

I have two text fields and a Button. I want to disable the Button unless both EditText-Fields are not empty. I tried many solutions here at stackoverflow, but they don\'t wo

7条回答
  •  鱼传尺愫
    2020-12-31 04:55

    A different way to do this would be

    b.setEnabled(!s1.trim().isEmpty() && !s2.trim().isEmpty());
    

提交回复
热议问题