我试图在webview中显示这个但是这段代码给了我一个“无效的转义序列”错误,任何人都可以提供任何帮助吗?
String html_value = "<p><\/p>\n<p> <img class=\"editorimg\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/social-staticdata\/uploads\/2014\/12\/1419995450.png\" alt=\"\" width=\"630\" \/><\/p>\n<p><strong><span style=\"text-decoration: underline;\">Food<\/span><\/strong><\/p>\n<p>*Includes lettuce, tomato, grilled onion, pickle, etc<\/p>\n<p>Hamburger<\/p>\n<p>Chicken Breast or Thigh Sandwich<\/p>\n<p>Hot Dog on bun<\/p>\n<p>Israeli Salad<\/p>\n<p>Chips, Salsa, Humus<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Drinks<\/strong><\/span><\/p>\n<p>Soda<\/p>\n<p>Wine (Cab, Merlot, Zin, Chardonay, Moscato)<\/p>\n<p>Champagne<\/p>\n<p>Beer (select micro brews)<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Seating<\/span><\/strong><\/p>\n<p>Inside and out (if outside, we have heaters and chairs)<\/p>";
mWebView.loadData(html_value,"text/html","UTF-8");
答案 0 :(得分:1)
您必须在webview中显示文本,然后首先将该文本复制到字符串中,然后将其显示为
private String data ="</p>\n</p>\nFood</span></strong></p>\n*Includes lettuce, tomato, grilled onion, pickle, etc</p>\nHamburger</p>\nChicken Breast or Thigh Sandwich</p>\nHot Dog on bun</p>\nIsraeli Salad</p>\nChips, Salsa, Humus</p>\nDrinks</strong></span></p>\nSoda</p>\nWine (Cab, Merlot, Zin, Chardonay, Moscato)</p>\nChampagne</p>\nBeer (select micro brews)</p>\nSeating</span></strong></p>\nInside and out (if outside, we have heaters and chairs)</p>";
webview.loadData(data , "text/html", "utf-8");