解析数据
JsonParser parser = new JsonParser();
//将JSON的String 转成一个JsonArray对象
JsonArray jsonArray1 = parser.parse(str).getAsJsonArray();
Gson gson = new Gson();
ArrayList<Sports> userBeanList = new ArrayList<>();
// 加强for循环遍历JsonArray
for (JsonElement user : jsonArray1) {
//使用GSON,直接转成Bean对象
Sports userBean = gson.fromJson(user, Sports.class);
userBeanList.add(userBean);
}
mMyAdapter = new MyAdapter3(getContext(),userBeanList);
mListView.setAdapter(mMyAdapter);