4

Android Html.fromHtml function auto converts undesired text into hyperlinks.

Here is my code:

 String htmlContent= "corners of nail.It has to";
 textViewContent.setTextHtml.fromHtml(htmlContent));
 textViewContent.setText(comment.getContent());

In above code Html.fromHtml treats "nails.It" as a link and converts it into hyperlink.

Here is the result of converted string. enter image description here

One of the solution which I could think is, put space after fullstop. Is there any good solution?

L4c0573
  • 333
  • 1
  • 7
  • 23
Rushikesh Talokar
  • 1,515
  • 4
  • 16
  • 32

2 Answers2

2

You can try something like this.

  textViewContent.setText( Html.fromHtml("<a href=\"YOURDESIREDLINK.COM\">YOUR DESIRED TEXT</a>"));
  textViewContent. setMovementMethod(LinkMovementMethod.getInstance());

Hope it helps.

Kristo
  • 1,339
  • 12
  • 22
0

Provide space between dot and second statement

     String htmlContent= "corners of nail. It has to";
     textViewContent.setTextHtml.fromHtml(htmlContent));
     textViewContent.setText(comment.getContent());
Rajan Kali
  • 12,627
  • 3
  • 25
  • 37