Open shahimclt opened 6 years ago
I dug through the code a little bit and I think adding a new method getLabelColor
to DateLabelAdapter
will do the trick. @badoualy what do you think?
If memory serves, for this case I used CharSequence
with ForegroundColorSpan
I'll check for the label color, I'll add when I have some time (or you can if you want to do a PR).
Wow. I didn't know you could do that with a CharSequence
. So thanks a lot for that.
This is what I am going with :
public CharSequence getLabel(Calendar calendar, int index) {
SpannableStringBuilder builder = new SpannableStringBuilder();
String red = "full";
SpannableString redSpannable= new SpannableString(red);
redSpannable.setSpan(new ForegroundColorSpan(Color.BLUE), 0, red.length(), 0);
builder.append(redSpannable);
return builder;
}
So now I suppose there is no need for a PR. Maybe you can include this snippet in the readme so that others can benefit.
Yeah, but using span if you're always using the same color is not the best idea, complicates life for nothing :) Tip, following code is simpler/more optimized:
SpannableString span = new SpannableString("full");
span.setSpan(new ForegroundColorSpan(Color.BLUE), 0, span.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
return span;
Yes, I did that. The code I posted was a generic one lifted from Stack Overflow. I am using the simpler version in my project. Thanks.
The GIF in the readme shows labels with different colors:
but I don't see any mention of how to do that. Please advise.