1

I tried just setting android:textColor="#FFFFFF" and this didn't work so I checked other answers to the problem to find solutions.

I tried making a selector and then setting the android:textColor attribute to this selector:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:color="#ffffff" />
<item android:state_focused="true" android:state_pressed="true" android:color="#ffffff" />
<item android:state_focused="false" android:state_pressed="true" android:color="#ffffff" />
<item android:color="#ffffff" />
</selector>

That didn't work either.

I tried setting the text color programmatically: verifyButton.setTextColor(getApplication().getResources().getColor(R.color.white));

That didn't work either. The button text color is a dark grey and I can't seem to change it to white.

Jay Rathod RJ
  • 10,843
  • 5
  • 33
  • 56
Questioner
  • 2,301
  • 3
  • 28
  • 49

1 Answers1

2

You can try with

setTextColor(Color.parseColor("#FFFFFF"));

FYI

Why calling getApplication() ?

getApplication() is only available on the Activity class and in the Service class, whereas getApplicationContext() is declared in the Context class.

  • You should call getApplicationContext() instead of getApplication() .

    setTextColor(getApplicationContext().getResources().getColor(R.color.white));

You should call getApplicationContext() or Direct Activity Class .

Return the context of the single, global Application object of the current process.

getApplication() vs. getApplicationContext()

Community
  • 1
  • 1
IntelliJ Amiya
  • 73,189
  • 14
  • 161
  • 193