在arraylist上显示Json文件,我想从json文件中显示arraylist中的所有名称。
try {
JSONArray root = new JSONArray(json);
for (int i = 0; i < root.length(); i++)
{
JSONObject att = (JSONObject) root.getJSONObject(i);
name = att.getString("nm");
list.add(name);
}
for(int i = 0; i<root.length(); i++){
Log.i("name", name);
}
}catch (JSONException e) {
e.printStackTrace();
}
答案 0 :(得分:1)
try{
JSONArray root = new JSONArray(json);
for (int i = 0; i < root.length(); i++){
JSONObject att = (JSONObject) root.getJSONObject(i);
name = att.getString("nm");
list.add(name);
}
for(int j = 0; j<feedList.size(); j++){
Log.i("name",feedList.get(j));
}
}catch (JSONException e) {
e.printStackTrace();
}