License Public Domain
Lines 16
Keywords
Android 2.0 (1) click (1) ClickableSpan (1) MovementMethod (1) Spannable (1) text (3) TextView (1)
Permissions
Owner: monkey103
Viewable by Everyone
Editable by monkey103's Friends
Hide
Don't get spied on – We respect your privacy and provide numerous options to protect it. Join Siafoo Now or Learn More

Android: make text spans clickable Atom Feed 0

# 's
 1TextView content = ((TextView) findViewById(R.id.content));
2// required to make ClickableSpans clickable
3content.setMovementMethod(LinkMovementMethod.getInstance());
4content.setText("Some text.", BufferType.SPANNABLE);
5
6Spannable spans = (Spannable) content.getText();
7ClickableSpan clickSpan = new ClickableSpan() {
8 @Override
9 public void onClick(View widget) {
10 // do stuff
11 }
12
13 public void updateDrawState(TextPaint ds) {
14 // override link-centric text appearance
15 }
16};
17spans.setSpan(clickSpan, 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);