求助一个关于OKhttp的问题

有生之莲萨摩耶 有生之莲萨摩耶 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用Okhttp请求数据,数据获得了但是没有传到类里,请问这个怎么解决

protected void loadData() {
OkhttpUtil.sendOKHttpRequest(url, new Callback() {
@Override
public void onFailure(Call call, IOException e) {

}

@Override
public void onResponse(Call call, Response response) throws IOException {
responseData=response.body().string();
parseJSONWithJSONObject(responseData);
Log.d("DomesticFragment","onResponse"+responseData);


}


});
}
private void parseJSONWithJSONObject(String responseData) {
try {
JSONArray jsonArray=new JSONArray(responseData);
Log.d("jsonArray", jsonArray.toString());
for (int i=0;i<jsonArray.length();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
Log.d("DomesticFragment","Array"+jsonArray.toString());
Log.d("DomesticFragment","object"+jsonObject.toString());
String subject=jsonObject.getString("subject");
String abs=jsonObject.getString("abstract");
String author=jsonObject.getString("author");

DomesdicInfo info=new DomesdicInfo(subject,author,abs,
"aa","bb","cc");
mList.add(info);
}

} catch (JSONException e) {
e.printStackTrace();
}

}

在上面的代码中,Log都已经获得了数据,可是数据就是无法获得,请问怎么解决
...全文
评论 10
收藏 已收藏
分享
返回顶部
有生之莲萨摩耶
Android 80,489 成员 91,371 内容