Search code examples
javaandroidstringreplacestring-parsing

Adding HTML tags around text in Java


Get a string from server "Hello, my e-mail email@email.com write here please". Need to surround email with HTML tags and make such string

"Hello, my e-mail <a href="mailto:email@email.com">email@email.com</a> write here please"

How can I make it in Java? I need to make it because I need to paste formatted string in TextView.setText(Html.fromHtml())


Solution

  • You can add android:autoLink="email" on your TextView xml tag.