简体   繁体   中英

Display a rich html textbox into a text view in android

I have a rich textview (I don't know the exact name of it but it shown in the image below) in admin control panel that allow the admin to write the description of product HTML对话框

and I have an api that return the code of this textbox and it return something like this for the above text:

<ul><li>Simple product with user role price activited</li><li>Without flavor and size<br></li></ul>

My question is how can I display this kind of rich text view code into text view in my apk

Edit: I tried to use fromHtml method but it doesn't work, maybe because I have html tags like ul and li ?

You can use WebView to display your HTML data like this

val webView = findViewById<WebView>(R.id.my_webview)
val text = "<ul><li>Simple product with user role price activited</li><li>Without flavor and size<br></li></ul>"
webView.loadDataWithBaseURL(null, text, "text/html", "utf-8", null)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM