我有一个问题:我的 json 解析器只显示最后一项!但在 Logcat 我看到了所有项目!你能帮助我吗?
@Override
protected void onPostExecute(JSONObject result) {
super.onPostExecute(result);
Log.d("Log", result.toString());
JSONObject jsn = result;
try {
JSONArray jarray = jsn.getJSONArray("item");
for (int i = 0; i < jarray.length(); i++){
JSONObject jsno = jarray.getJSONObject(i);
title.setText(Html.fromHtml("<a href=\""+jsno.getString("link")+"\">"+jsno.getString("title")+"</a>"));
cat.setText(jsno.getString("category"));
date.setText(jsno.getString("pubDate"));
desc.getSettings().setJavaScriptEnabled(true);
desc.getSettings().setDefaultTextEncodingName("charset=UTF-8"); desc.loadData(jsno.getString("description"), "text/html; charset=UTF-8", "utf-8");
}
} catch (JSONException e) {
e.printStackTrace();
}