0

My code,

if (position == 1) {
    return new DummyItem(String.valueOf(position), "  ABOUT "+"ME", String.valueOf(position));
} else if (position == 2) {
    return new DummyItem(String.valueOf(position), "  ABOUT "+"Office", String.valueOf(position));
}

Here in first case return value is "ABOUT ME". So I want to set pink color to "ABOUT ME". How to set color in Java code?

ABOUT ME text field is works like clickable field and when I click on "ABOUT ME" it will call aboutme.XML (xml contain just text/data).

Cœur
  • 34,719
  • 24
  • 185
  • 251
user2240097
  • 301
  • 3
  • 9

2 Answers2

0

For which Object you would like to set a Color? If you like to set the TextColor of an TextView you could try this: How to set the text color of TextView in code?

Community
  • 1
  • 1
Timo
  • 288
  • 1
  • 7
0

if you are trying this out in android's text view. use this as android M requires this. textView.setTextColor(ContextCompat.getColor(context, R.color.your_color));

vikas kumar
  • 9,263
  • 2
  • 42
  • 47