In Android, how to make Login button disable with respect to EditText?

前端 未结 9 2181
猫巷女王i
猫巷女王i 2020-12-28 09:50

If EditText is empty then Login Button has to be disabled. And if EditText has some texts then Login Button has to be ena

9条回答
  •  别那么骄傲
    2020-12-28 10:19

    I only want to add that the check will NOT work if the InputType of the EditText is a password (or similar) and the fuction to proof the length of the text (see other answers) is called from

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {...}
    

    So it is important to call the check from

    @Override 
    public void afterTextChanged(Editable s) {...}
    

提交回复
热议问题