/ Android

Creating HyperLinks in Large Text (TextView) - Android


<string name="totalText">Hello <u>World</u></string> 
public void hyperlinkWordsInText() 

Spanned sequence = html.fromhtml (context.getstring (r.string.totalText)); 

Spanablestringbuilder strbuilder = new Spanablestringbuilder(sequence); 

Underlinespan [] underlines = strbuilder.getspans (0, sequence.length (), Underlinespan.class); 

For (Underlinespan span : underlines) 


int start = strBuilder.getSpanStart(span); 

int end = strBuilder.getSpanEnd(span); 

int flags = strBuilder.getSpanFlags(span); 

ClickableSpan myActivityLauncher = new ClickableSpan() 


public void onClick(View view) 


// do wat ever u want on click 




Ramya Gangula

Ramya Gangula

I work as Android developer at GM financials. Before GM i worked at Samsung. The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way

Read More