Created
July 21, 2016 09:32
-
-
Save PPartisan/b1b9a5fdf9ae1afcf4e27a98f3c1f8cb to your computer and use it in GitHub Desktop.
Method for converting text to a SpannableString, depending on
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static SpannableString getSpannedString(String text, char... triggers) { | |
SpannableString spanString = new SpannableString(text); | |
for (int i = 0; i < spanString.length(); i++) { | |
for (char trigger : triggers) { | |
if (spanString.charAt(i) == trigger) { | |
spanString.setSpan(new ForegroundColorSpan(Color.CYAN), i, i+1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | |
} | |
} | |
} | |
return spanString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment