Code example for SpannableStringBuilder

Methods: charAt, insert, length, setSpan

0
		lVerseNumber.setText("");
	} 
 
	static void addXrefLink(final Context context, SpannableStringBuilder sb, final int ari, final int which, final VersesView.XrefListener xrefListener, final VersesView optionalVersesView) {
		// if last char of this sb is newline, move back. 
		int sb_start = sb.length();
		if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '\n') {
			sb_start --;
		} 
		 
		sb.insert(sb_start, " \u2022 "); 
		 
		sb.setSpan(new XrefAttrSpan(context), sb_start+1, sb_start+2, 0);
		sb.setSpan(new ClickableSpan() {
			@Override public void updateDrawState(TextPaint ds) { /* prevent underline */ }
			 
			@Override public void onClick(View widget) {
				if (xrefListener != null) {
					xrefListener.onXrefClick(optionalVersesView, ari, which);
				} 
			}