Remove extra line breaks after Html.fromHtml()

后端 未结 4 1592
花落未央
花落未央 2020-12-13 03:49

I am trying to place html into a TextView. Everything works perfectly, this is my code.

String htmlTxt = \"

Hellllo

\"; // the html is form
4条回答
  •  时光取名叫无心
    2020-12-13 04:38

    you can use this lines ... totally works ;)

    i know your problem solved but maybe some one find this useful .

    try{
            string= replceLast(string,"

    ", ""); string=replceLast(string,"

    ", ""); }catch (Exception e) {}

    and here is replaceLast ...

    public String replceLast(String yourString, String frist,String second)
    {
        StringBuilder b = new StringBuilder(yourString);
        b.replace(yourString.lastIndexOf(frist), yourString.lastIndexOf(frist)+frist.length(),second );
        return b.toString();
    }
    

提交回复
热议问题