I need to display a string programmatically in a textview with html formatting
eg. "find more information"+here" , where "here" can listen to onclick.
Is this possible or any other suggestions?
            Asked
            
        
        
            Active
            
        
            Viewed 47 times
        
    -2
            
            
         
    
    
        Phantômaxx
        
- 37,901
- 21
- 84
- 115
 
    
    
        Beulah Ana
        
- 360
- 2
- 14
- 
                    Does this help https://stackoverflow.com/questions/10696986/how-to-set-the-part-of-the-text-view-is-clickable – jayeshsolanki93 Dec 24 '17 at 07:34
- 
                    Possible duplicate of [How to set the part of the text view is clickable](https://stackoverflow.com/questions/10696986/how-to-set-the-part-of-the-text-view-is-clickable) – Michael Roland Dec 24 '17 at 10:59
1 Answers
0
            You can use SpannableString with ClickableSpan.
Here is an example.
SpannableString span= new SpannableString("Find more information "+here"");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
    // Perform action here
}
@Override
public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setUnderlineText(false);
}
};
span.setSpan(clickableSpan, 23, 26, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(span);
textView.setMovementMethod(LinkMovementMethod.getInstance());
 
    
    
        ADM
        
- 20,406
- 11
- 52
- 83