GridView列表数据的添加

/**
* 获取游戏列表数据
*/
private void getGameListData(String urlStr, String portStr) {
ArrayList list = new ArrayList();
HashMap map;
HttpConn httpConn = new HttpConn();
JSONObject jsonData = httpConn.urlConn(urlStr, portStr);
try {
JSONArray jsonArr = jsonData.getJSONArray("gameList");
for (int i = 0; i < jsonArr.length(); i++) {
String regionStr = ((JSONObject) jsonArr.opt(i))
.getString("language")
+ " " + ((JSONObject) jsonArr.opt(i)).getString("platform")
+ " " + ((JSONObject) jsonArr.opt(i)).getString("region");
map = new HashMap();
map.put("gameInfo", (JSONObject) jsonArr.opt(i));
map.put("name", ((JSONObject) jsonArr.opt(i)).getString("name"));
map.put("region", regionStr);
list.add(map);
}
SimpleAdapter sa = new SimpleAdapter(this, list,
R.layout.buy_list_item, new String[] { "name", "region" },
new int[] { R.id.item_name, R.id.item_region });
listGv.setAdapter(sa);
} catch (JSONException e) {
e.printStackTrace();
}
}

你可能感兴趣的:(GridView)