import
androidx.appcompat.app.AppCompatActivity;
import
android.os.Bundle;
import
android.text.Editable;
import
android.text.TextWatcher;
import
android.widget.Button;
import
android.widget.EditText;
class
MainActivity : AppCompatActivity() {
var etEmail: EditText? =
null
var etPassword: EditText? =
null
var bLogin: Button? =
null
private
val textWatcher: TextWatcher = object : TextWatcher {
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
val emailInput = etEmail!!.text.toString()
val passwordInput = etPassword!!.text.toString()
bLogin.setEnabled(!emailInput.isEmpty() && !passwordInput.isEmpty())
}
override fun afterTextChanged(s: Editable) {}
}
override fun onCreate(savedInstanceState: Bundle?) {
super
.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
etEmail = findViewById(R.id.etEmail)
etPassword = findViewById(R.id.etPassword)
bLogin = findViewById(R.id.loginButton)
etEmail.addTextChangedListener(textWatcher)
etPassword.addTextChangedListener(textWatcher)
}
}