【发布时间】:2017-01-27 15:46:56
【问题描述】:
我创建了一个 pojo 类.. 我存储从 api 获取的数据..
在 MainActivity.java 我使用 loopj 来解析 json 数据
storeList = new ArrayList<AllStore>();
try {
JSONArray jsonArray = new JSONArray(new String(responseBody));
for (int i = 0; i < jsonArray.length(); i++) {
store = new AllStore();
store.setLocation(jsonArray.getJSONObject(i).getString("storeName"));
store.setAddress(jsonArray.getJSONObject(i).getString("address"));
我的pojo课
AllStore.java
public class AllStore{
String storeName;
String address;
public AllStore(String storeName, String address){
this.storeName= storeName;
this.location = location;
}
public AllStore{
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
}
在其他java类中..而不是我在做的适配器类
AllStore allStore = new Allstore();
mText.setText(allStore.getStoreName);
这里 allStore.getStoreName 值为 null 显示..如何解决这个问题..
请帮忙
【问题讨论】:
-
使用调试器,顺便说一下 this.location = location;虽然构造函数中没有名为 location 的参数
-
您在此处提供的代码存在多个问题。它甚至不应该编译。
-
为什么是@lupz ??它的编译
标签: java android json instance pojo