android spanned string code example

Example: spannable string for multiple places same string

SimpleSpanBuilder ssbTest = new SimpleSpanBuilder();

ssbTest.append("Green",new ForegroundColorSpan(Color.GREEN));
ssbTest.append("Black",new ForegroundColorSpan(Color.BLACK));
ssbTest.append("Blue",new ForegroundColorSpan(Color.BLUE));
ssbTest.append("Red",new ForegroundColorSpan(Color.RED));

ssbTest.append("Green",new ForegroundColorSpan(Color.GREEN));
ssbTest.append("Black",new ForegroundColorSpan(Color.BLACK));
ssbTest.append("Blue",new ForegroundColorSpan(Color.BLUE));
ssbTest.append("Red",new ForegroundColorSpan(Color.RED));


textView.setText(ssbTest.build());

Tags:

Misc Example