如果填充了 2 个编辑文本,如何启用按钮?

how to enable button if 2 edit text is fill?

如果使用 2 个编辑文本填充,如何启用按钮 'androidx.core:core-ktx:1.1.0'?

override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        editTextEmailOrPhone.doOnTextChanged { emailOrPhone, _, _, _ ->
            if (isValidEmailOrPhone(emailOrPhone.toString())) {
                buttonLogin.isEnabled = true
            } else {
                edtPassword.doOnTextChanged { password, _, _, _ ->
                buttonLogin.isEnabled = password.toString().length >= 8
                }
            }
        }
    }

    private fun isValidEmailOrPhone(text: String): Boolean =
        android.util.Patterns.EMAIL_ADDRESS.matcher(text).matches() || android.util.Patterns.PHONE.matcher(
            text
        ).matches()

我试过了。如果我填写电子邮件(启用按钮)<==看起来不错

但是,如果我删除电子邮件(按钮未禁用)<== 问题

edtPassword.doOnTextChanged { password, _, _, _ ->
    onInfoChange(password?.toString(), editTextEmailOrPhone.text?.toString())
}
editTextEmailOrPhone.doOnTextChanged { emailOrPhone, _, _, _ ->
    onInfoChange(edtPassword.text?.toString(), emailOrPhone?.toString())
}
private fun onInfoChange(password : String?, emailOrPhone : String?){
    buttonLogin.isEnabled = isValidEmailOrPhone(emailOrPhone) && password?.length ?: 0 >= 8
}