MrJoshFisher MrJoshFisher - 11 days ago 5x
Android Question

Disable login button till form is filled android sdk

Hello all simple question how do you disable the submit button till to edittext are filled is it an if command or something ??

b = (Button)findViewById(;
et = (EditText)findViewById(;
pass= (EditText)findViewById(;

if (et & pass == ' ') {


b.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog =, "",
"Validating user...", true);
new Thread(new Runnable() {
public void run() {


What you might want to do is use a TextWatcher and in onTextChanged() check to see if each is empty. But you want to check the text not the View so instead of checking et and pass, you probably want to get the String in each.

String etString = et.getText().toString();
String passString = pass.getText().toString();

If they are not emty and null, plus any other checks you want such as length then