0

I want to create a button which is disabled. Only way to enable it if user inputs correct details and after the user clicks submit, if the details provided is correct, the button is enabled to go further.

Aagam Shah
  • 125
  • 3
  • 11

3 Answers3

1

set this property on initializing the button in your class

button.setClickable(false); // by default it is disable

put this code in your submit button onClickListenser to check input validity eg

if(validateUserInput()) //check for the validation of your logic in a fuction
button.setClickable(true);
else
button.setClickable(false);

function validateUserInput

private boolean validateUserInput(){
//your logic here for validation
if(your check)
return true;
else
return false;
}
Sultan
  • 119
  • 1
  • 12
0

Use these lines where you need to make button disabled or enabled.

button.isEnabled=false OR button.isEnabled=true

MMG
  • 3,226
  • 5
  • 16
  • 43
0

You can disable it on code with Button.setEnabled(false); then later you you can turn it on when the submit button is pressed with Button.setEnabled(true);

Talha
  • 9
  • 2