嗨,我这里有一个脚本
http://myprocity.com/android/fetchthecity.php
这将返回一个数组数组。我想在 Android 中解析这个并存储每个值。
我现在的代码是这样的,也许这是有缺陷的?我什么都没有出现
public static void refreshFeed(Activity act){
ActionEngine.swamiOn = false;
FetchTheCityTask f = new FetchTheCityTask(act);
f.execute();
try {
if (f.get() != null) {
JSONArray feedArr = new JSONArray();
feedArr = json.getJSONArray("data");
ArrayList<UserRecord> items = new ArrayList<UserRecord>();
for(int i = 0; i < feedArr.length(); i++){
for(int j = 0; j < feedArr.getJSONArray(i).length(); j++) {
JSONObject row = feedArr.getJSONArray(i).getJSONObject(j);
String item = row.getString("Item");
String descp = row.getString("Description");
String pic = row.getString("PicPath");
String time = row.getString("Time");
String donatedby = row.getString("DonatedBy");
String ebase = row.getString("Ebase");
String cond = row.getString("Condition");
String loc = row.getString("Location");
items.add(new UserRecord(item,descp,pic,time,donatedby,
ebase,cond,loc));
}
}
TheCityFragment.feedArea.setAdapter(new UserItemAdapter(act,
android.R.layout.simple_list_item_1, items));