sam dev
sam dev

Reputation: 21

How to set different colors for textview in recyclerview adapter class

In my application i need to set different colors for text view in recycler view adapter class, can anyone help me to solve this issue.

Upvotes: 0

Views: 270

Answers (1)

Kalai
Kalai

Reputation: 543

In your onBindViewHolder, obtain the text view via the respective ViewHolder and simply call setTextColor on it with the appropriate color ( Ideally this could be based on the data at the specified position from onBindViewHolder).

If you want different colors within a single text view, you could follow the link to the answer provided by @SebastienRieu in the comments.

I think this codelab might be helpful for you.

Upvotes: 1

Related Questions