Android examples for User Interface:TextView
set Colorful Text to TextView
//package com.java2s; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.widget.TextView; public class Main { public static void setColorfulText(int startPos, int endPos, String text, int color, TextView tv) { SpannableStringBuilder builder = new SpannableStringBuilder(text); builder.setSpan(new ForegroundColorSpan(color), startPos, endPos, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(builder);//from w w w . jav a2 s . co m } }