如何在Android中将Json数据加载到WebView? [英] How can I load Json data to WebView in Android?

查看:98
本文介绍了如何在Android中将Json数据加载到WebView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解析HTML格式的JSON数据.我不知道如何实现它.

I am trying to parse JSON data which is in HTML format. I am not understanding how to implement it.

我的JsonObject如下所示:

My JsonObject as shown below :

{"Content":
{
"PageContent":"<table cellpadding=\"1\" cellspacing=\"0\">\r\n\t<tr><td colspan=\"2\" style=\"font-weight:bold; font-style:italic; font-size:24px; color:Red; text-decoration:blink;\">Contact Us</td></table>"
}
}

我想将HTML格式的jsonobject i.e. menuPageContent加载到WebView.

I want to load jsonobject i.e. menuPageContent which is HTML format to WebView.

推荐答案

希望您知道仍然,这是一种从json上方获取menuPageContent的方法:

Still, here is a way to get menuPageContent from above json:

String myJSONData = "place your data here";
JSONObject objJSON = new JSONObject(myJSONData);
JSONObject subObj = objJSON.getJSONObject("MenuContent");
String webData = subObj.getString("menuPageContent");

myWebView.loadData(webData, "text/html; charset=UTF-8", null);

详细了解 WebView .

这篇关于如何在Android中将Json数据加载到WebView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆