本文实例为大家分享了Android九宫格图片展示的具体代码,供大家参考,具体内容如下
1、需要的网络JSON数据
2、数据实现类
package chenglong.activitytest.pengintohospital.entity; import org.json.JSONException; import org.json.JSONObject; /** * * 科室 * Created by LICHENGLONG on 2017-10-02. */ public class BasSection { public Integer id;//科室id public String sectionName;//科室名称 public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getSectionName() { return sectionName; } public void setSectionName(String sectionName) { this.sectionName = sectionName; } public BasSection(Integer id, String sectionName){ this.id = id; this.sectionName = sectionName; } public static BasSection sectionData(JSONObject json){ try { return new BasSection( json.getInt("id"), json.getString("sectionName"); } catch (JSONException e) { e.printStackTrace(); } return null; } }
3、创建List集合接收数据
ListlistBasSection = new ArrayList<>();
4、获取JSON数据
/** * 获取JSON科室数据 */ public void findSectionData(){ AsyncHttpClient client = new AsyncHttpClient(); //你的JSON数据链接地址 client.get(AbAppConfig.DATA_URL + "appGVConsultation/findSectionData", null, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { JSONObject object = new JSONObject(new String(responseBody));//获取json数据 JSONArray jsonArray = object.getJSONArray("obj");//获取数据集名称为obj的数据 Log.d("jsonArray数据输出:", String.valueOf(jsonArray)); for (int i = 0; i < jsonArray.length();i++) { BasSection novels = BasSection.sectionData(jsonArray.getJSONObject(i));//把数据存在novels集合中 if (novels != null){ listBasSection.add(novels); } } } catch (JSONException e) { Toast.makeText(GV_Consultation.this, "数据请求失败,请稍后重试", Toast.LENGTH_SHORT).show(); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { //请求失败的回调处理 Toast.makeText(GV_Consultation.this, "请链接网络,稍后重试", Toast.LENGTH_SHORT).show(); } }); }
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔