Android Html.fromHtml function automatically converts unwanted text into hyperlinks

The Android function Html.fromHtml automatically converts unwanted text into hyperlinks.

Here is my code:

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

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

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

One solution I could think of is to put in a place after a full break. Is there a good solution?

+4
source share
2 answers

Provide a space between the point and the second statement

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

You can try something like this.

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

Hope this helps.

0
source

Source: https://habr.com/ru/post/1629153/


All Articles