最新下载
热门教程
- 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 - 8
 - 9
 - 10
 
Android Studio获取网络JSON数据并处理的方法
时间:2022-06-25 23:18:37 编辑:袖梨 来源:一聚教程网
本文实例为大家分享了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 
相关文章
- 王者荣耀西施奖励网站在哪进 西施奖励最新网页在线入口 11-04
 - 超自然行动组可用的兑换码有哪些 2025最新有效兑换码领取 11-04
 - 超自然行动组官网入口是什么 超自然官网网页在线充值入口 11-04
 - 我的世界物品怎么一键丢弃 mc快捷键使用指南 11-04
 - 我的世界聊天栏怎么打开 mc聊天快捷操作说明 11-04
 - 我的世界创造模式快捷栏怎么保存 mc物品栏管理技巧 11-04
 
            
                                
                                
                                
                                
                                            
                                        
                                            
                                        
                                            
                                        
                                            
                                        
                                            
                                        
                                            
                                        
                                            
                                        
                                            
                                        
                                            
                                        
                                            
                                        