Back to project page OpenCmsMobile-AndroidApp.
The source code is released under:
GNU Lesser General Public License
If you think the Android project OpenCmsMobile-AndroidApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package cz.nelasoft.opencms.mobile; //from ww w.j a v a2s .c om import android.graphics.Typeface; import android.text.SpannableStringBuilder; import android.text.style.CharacterStyle; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; public class StyleableSpannableStringBuilder extends SpannableStringBuilder { public StyleableSpannableStringBuilder appendWithStyle(CharSequence text, CharacterStyle... c) { super.append(text); int startPos = length() - text.length(); for (CharacterStyle cs : c) { setSpan(cs, startPos, length(), 0); } return this; } public StyleableSpannableStringBuilder appendBold(CharSequence text) { return appendWithStyle(text, new StyleSpan(Typeface.BOLD)); } public StyleableSpannableStringBuilder appendColor(CharSequence text, int color) { return appendWithStyle(text, new ForegroundColorSpan(color)); } public StyleableSpannableStringBuilder appendColorBold(CharSequence text, int color) { return appendWithStyle(text, new StyleSpan(Typeface.BOLD), new ForegroundColorSpan(color)); } }