EditText passwordInput = findViewById(R.id.password_input); String password = passwordInput.getText().toString(); if (password.length() < 8) { passwordInput.setError("Password must be at least 8 characters long"); }
EditText emailInput = findViewById(R.id.email_input); String email = emailInput.getText().toString(); if (isValidEmail(email)) { emailInput.setError(null); } else { emailInput.setError("Please enter a valid email address"); }The EditText widget and its setError method are part of the android.widget package library in Android.