我想在TextView
中显示HTML数据,但无法解析TextView
中的所有html标记。所以,我在loadDataWithBaseURL
中了解了WebView
。
我尝试了下面的代码,但它什么也没做,并按原样显示HTML数据。如何防止这个问题?
我的代码:
webView.loadDataWithBaseURL(null, string, "text/html", "utf-8", null);
我的字符串:
<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> is a system of mathematics consisting of a list of 16 basic <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, <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>
答案 0 :(得分:0)
尝试使用WebView的这种方法:
webView.loadData(htmlString, "text/html", "UTF-8");