ClickableSpan点击链接事件

public Spannable getProfileLink(final Context context) { 
   
final String name = firstName + " " + lastName; 
   
Spannable spans = SpannableStringBuilder.valueOf(name); 
   
ClickableSpan clickSpan = new ClickableSpan() { 
       
@Override 
       
public void onClick(View widget) { 
           
// TODO - call profile here 
           
Toast.makeText(context, "Will call profile", Toast.LENGTH_LONG); 
       
} 
 
   
}; 
    spans
.setSpan(clickSpan, 0, name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 
   
return spans; 
} 

你可能感兴趣的:(click)