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
  • 37,241
  • 25
  • 195
  • 267
user2240097
  • 311
  • 3
  • 11

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
  • 298
  • 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
  • 10,447
  • 2
  • 46
  • 52