这是我的代码,
ScrollView
我正在使用排球库。在此程序中,我正在传递page_id = 37并获得响应,但是我无法在此行中将对象中的html响应设置为webview。
final JsonObjectRequest obreq = new JsonObjectRequest(Request.Method.POST, JSON_URL,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
//hiding the progressbar after completion
/*progressBar.setVisibility(View.INVISIBLE);*/
try {
//getting the whole json object from the response
JSONObject obj = response.getJSONObject("data");
String color = obj.getString("data");
String desc = obj.getString("content");
data += "content: " + color +
"content_heading : " + desc;
/*mWebView.loadData(data, "text/html; charset=utf-8", "UTF-8");*/
mWebView.loadData(data, "text/html; charset=utf-8", "UTF-8");
//we have the array named hero inside the object
//so here we are getting that json array
/* JSONArray cmsArray = obj.getJSONArray("data");*/
/*//now looping through all the elements of the json array
for (int i = 0; i < cmsArray.length(); i++) {
//getting the json object of the particular index inside the array
JSONObject cmsObject = cmsArray.getJSONObject(i);
//creating a hero object and giving them the values from json object
Cms cms = new Cms(cmsObject.getString("content"), cmsObject.getString("content_heading"), cmsObject.getInt("page_id"));
}*/
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//displaying the error in toast if occurrs
Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("page_id", "37");
return params;
}
};
VolleySingleton.getInstance(getActivity()).addToRequestQueue(obreq);
}
在JSONObjectRequest中抛出此错误JSONObjectRequest()无法应用。
我正在从json接收html数据对象中的响应,我想在导致错误的webview中显示该响应。谁能帮助我解决这个问题?