3

I am trying to assign a color from my colors.xml file to the my tableLayout with the following code:

tabLayout.setSelectedTabIndicatorColor(Color.parseColor(getResources().getString(R.color.colorMain)));

But I get an error: "Expected resource of type string..."
I have tried different things from other threads
1. Changed my minSdkVersion in gradle and Android Studio to 23
2. Tried to disable lint rule in your build.gradle discribed here.

None of them worked and I still get the error message.

Community
  • 1
  • 1
Code Pope
  • 5,075
  • 8
  • 26
  • 68

1 Answers1

0

Replace it with

tabLayout.setSelectedTabIndicatorColor(Color.parseColor(getResources().getColor(R.color.colorMain)));

or try

tabLayout.setSelectedTabIndicatorColor(Color.parseColor(getResources().getColor(getResources(), R.color.colorMain, null)));
Rahul Kishan
  • 314
  • 4
  • 18
  • None of them works for me. I get an error message: parsColor(java.lang.String)in Color cannot be applied to (int). – Code Pope Jan 08 '17 at 21:15