簡體   English   中英

在Android中刪除HTML並顯示項目符號而不是li標簽

[英]remove HTML and show bullet instead of li tag in Android

我想remove HTML and show bullet instead of <li> in Android

刪除html的方法:

public static String removeHTML(String value){
    value = value.replace("<ul style=\"list-style-type: disc;\">" , "<ul>");
    value = value.replace("<ul>" , "");
    value = value.replace("</ul>" , "");
    value = value.replace("<li>" , " &#8226 "); // Bullet
    value = value.replace("</li>" , "");
    value = value.replace("<p>" , "");
    value = value.replace("</p>" , "<br />");
    value = value.replace("<br />" , " \n ");
    return Html.fromHtml(value).toString();
}

內容是:

title goes here
    <ul style=\"list-style-type: disc;\">
        <li>line one</li>
        <li>line two</li>
        <li>line three</li>
        <li>line four</li>
     </ul>

但是當我打印系統日志時顯示:

title goes here
    •
line one
    •
line two
    •
line three
    •
line four

我很確定您的字符串在子彈前后都有\\n字符。 刪除所有\\n

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM