【发布时间】:2018-08-25 03:03:05
【问题描述】:
我正在使用快速 Android 网络库。 Json 响应有效。我在 logcat 中得到了整个 json 字符串。如何在此库的列表视图中的 textview 或 jsonarray 中显示特定的 json 对象或字符串。请帮助,在此先感谢。
JSONObject json = new JSONObject();
try {
json.put("email", loggedInUser);
} catch (JSONException e) {
e.printStackTrace();
}
Log.e("JSON", json.toString());
AndroidNetworking.post(Constants.read_profile)
.addBodyParameter("json", json.toString())
.setTag("test")
.setPriority(Priority.MEDIUM)
.build()
.getAsJSONObject(new JSONObjectRequestListener() {
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onResponse(JSONObject response) {
Log.e("READ", response.toString());
}
@Override
public void onError(ANError anError) {
Log.e("READ", anError.toString());
}
});
【问题讨论】:
-
你可以使用gson库解析你得到的json,使用模型类,使用gson设置数据到模型类,需要的时候取回来。
-
粘贴您的 JSON 日志
标签: java android json xml android-layout