ClickableSpan multiple code example
Example: ClickableSpan multiple
1 private void makeTagLinks(final String text, final TextView tv) {
2 if (text == null || tv == null) {
3 return;
4 }
5 final SpannableString ss = new SpannableString(text);
6 final List items = Arrays.asList(text.split("\\s*,\\s
7 int start = 0, end;
8 for (final String item : items) {
9 end = start + item.length();
10 if (start < end) {
11 ss.setSpan(new MyClickableSpan(item), start, end, 0);
12 }
13 start += item.length() + 2;
14 }
15 tv.setMovementMethod(LinkMovementMethod.getInstance());
16 tv.setText(ss, TextView.BufferType.SPANNABLE);
17 }