简体   繁体   English

在Android的WebView的loadDataWithBaseURL中解析HTML数据

[英]Parse HTML Data in loadDataWithBaseURL of WebView in Android

I want to display HTML Data in TextView but It was not possible to parse all html tags in TextView . 我想在TextView显示HTML数据,但是无法解析TextView所有html标签。 So, I came to know about loadDataWithBaseURL in WebView . 因此,我开始了解WebView loadDataWithBaseURL

I tried following code but it is doing nothing and displaying HTML Data as it is. 我尝试了下面的代码,但是它什么也不做,并按原样显示HTML数据。 How to prevent this issue ? 如何预防这个问题?

My Code : 我的代码:

webView.loadDataWithBaseURL(null, string, "text/html", "utf-8", null);

My String : 我的弦:

<p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; color: rgb(51, 51, 51); font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; text-align: justify; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> <b style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;">Vedic Mathematics</b>&nbsp;is a system of mathematics consisting of a list of 16 basic&nbsp;<em style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;">sutras</em>, or aphorisms. They were presented by a Hindu scholar and mathematician,&nbsp;<span class="mw-redirect" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;">Bharati Krishna Tirthaji Maharaja</span>, during the early part of the 20th century.</p> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; color: rgb(51, 51, 51); font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; text-align: justify; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> The calculation strategies provided by Vedic mathematics are said to be creative and useful, and can be applied in a number of ways to calculation methods in arithmetic and algebra.</p> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; color: rgb(51, 51, 51); font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; text-align: justify; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> 16 Sutras translated in English (from Sanskrit) are:</p> <ol style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; color: rgb(51, 51, 51); font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; background: transparent;"> By one more than the one before</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> All from 9 and the last from 10</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> Vertically and Cross-wise</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> Transpose and Apply</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> If the Samuccaya is the Same it is Zero</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> If One is in Ratio the Other is Zero</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> By Addition and by Subtraction</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> By the Completion or Non-Completion</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> Differential Calculus</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> By the Deficiency</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> Specific and General</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> The Remainders by the Last Digit</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> The Ultimate and Twice the Penultimate</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> By One Less than the One Before</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> The Product of the Sums</li> <li style="margin: 0px 0px 0px 30px; padding: 0px; border: 0px; outline: 0px; line-height: 21.600000381469727px; text-align: justify; background: transparent;"> All the Multipliers</li> </ol> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; color: rgb(51, 51, 51); font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; text-align: justify; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> It is amazing that with the help of Vedic Mathematics, you will be able to solve or calculate complex mathematical problems mentally.</p> <h3 style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; font-size: 15px; font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; color: rgb(51, 51, 51); background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> By one more than the previous one</h3> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; color: rgb(51, 51, 51); font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> <b style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;">1. Square of numbers ending in 5</b></p> <blockquote style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; font-size: 14px; quotes: none; font-family: Georgia, Times, serif; color: rgb(51, 51, 51); background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"> 65 x 65 = (6 x (6+1) ) 25 = (6x7) 25 = 4225</p> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"> 45 x 45 = (4 x (4+1) ) 25 = (4x5) 25 = 2025</p> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"> 105 x 105 = (10 x (10+1) 25 = (10 x 11) 25 = 11025</p> </blockquote> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; color: rgb(51, 51, 51); font-family: 'Segoe UI', Arial, Helvetica, sans-serif; line-height: 18px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> <b style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;">2. When sum of the last digits is 10 and previous parts are the same</b></p> <blockquote style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; font-size: 14px; quotes: none; font-family: Georgia, Times, serif; color: rgb(51, 51, 51); background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"> 44 x 46 = (4 x (4+1)) (4 x 6) = (4 x 5) (4 x 6) = 2024</p> <p style="margin: 15px 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"> 37 x 33 = (3 x (3+1)) (7 x 3) = (3 x 4) (7 x 3) = 1221</p> </blockquote> <span style="color: rgb(51, 51, 51); font-family: Georgia, Times, serif; font-size: 14px; background-color: transparent;">11 x 19 = (1 x (1+1)) (1 x 9) = (1 x 2) (1 x 9) = 209</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

尝试使用此WebView方法:

webView.loadData(htmlString, "text/html", "UTF-8");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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