I have a loginscreen. In this loginscreen I have a button that is by default disabled.
When the user has entered 4 numbers I enable the button and change the textcolor to green.
But when the 4 numbers are not the correct code I clear my edittext and disable my button again.
At the moment the textcolor of this disabled button is offcourse green. How can I set it back to the default color?
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(s.length() >= maxLength)
{
btnOk.setEnabled(true);
btnOk.setTextColor(Color.parseColor("#00B32D"));
}
else
{
btnOk.setEnabled(false);
}
private void checkIfValid(String inputPin)
{
if(inputPin.equals("0000"))
{
startActivity(new Intent(this, ShowScreenActivity.class));
finish();
}
else
{
clearText();
====> //Here i want to set my textcolor back to normal.
Toast.makeText(this, "Pincode foutief", Toast.LENGTH_SHORT).show();
}
}
Get the default color of Button using this code,
int DefaultButtonColor = btnOk.getTextColors().getDefaultColor();
If its not what you are looking for, then you can get Android Platform Resource Color using
something like,
android.R.color.secondary_text_dark
Check others too...
Back up your default color in onCreate();
defaultTextColor = btnOk.getTextColors().getDefaultColor();
Then set it back
btn.setTextColor(defaultTextColor);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With