Created
August 13, 2018 03:49
-
-
Save KanshuYokoo/8a571dd7cec79d8b6369d44e9b95bc9a to your computer and use it in GitHub Desktop.
Android, checking if login credentials are filled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginActivity extends AppCompatActivity implements View.OnClickListener, TextWatcher { | |
userData user; | |
private Button mLoginButton; | |
private EditText mLoginID; | |
private EditText mLoginPW; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
mLoginID = findViewById(R.id.loginEdit); | |
mLoginPW = findViewById(R.id.passwordEdit); | |
mLoginID.addTextChangedListener(this); | |
mLoginPW.addTextChangedListener(this); | |
mLoginButton =(Button)findViewById(R.id.loginButton); | |
mLoginButton.setEnabled(false); | |
} | |
@Override | |
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { | |
} | |
@Override | |
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { | |
mLoginButton.setEnabled(mLoginID.getText().length() > 0 && mLoginPW.getText().length() > 0); | |
} | |
@Override | |
public void afterTextChanged(Editable editable) { | |
} | |
@Override | |
public void onClick(View view) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment