Java 在android中,我的pojo类实例得到的是null值

Java 在android中,我的pojo类实例得到的是null值,java,android,json,instance,pojo,Java,Android,Json,Instance,Pojo,我已经创建了一个pojo类。。我存储从api获取的数据的地方 在MainActivity.java中,我使用loopj解析json数据 storeList = new ArrayList<AllStore>(); try { JSONArray jsonArray = new JSONArray(new String(responseBody)); for (int i =

我已经创建了一个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"));
在其他java类中。。而不是适配器类

AllStore allStore = new Allstore();

mText.setText(allStore.getStoreName);
此处allStore.getStoreName值为空,显示。。如何解决这个问题

请帮忙

AllStore allStore = new Allstore();

mText.setText(allStore.getStoreName());
在这里,您将使用默认构造函数创建一个新的对象Allstore

public AllStore{

}
如果调用
.getStoreName
,它将返回null,因为您没有设置任何值

在另一种方法中,必须在te数组列表中添加store对象

store.setLocation(jsonArray.getJSONObject(i).getString("storeName"));        
store.setAddress(jsonArray.getJSONObject(i).getString("address"));
storeList.add(store);
稍后,如果要使用列表中项目的名称,可以执行以下操作:

mText.setText(storelist.get(index).getStoreName());

其中,
索引
是项目列表中的位置。

使用调试器,顺便说一下,this.location=location;虽然构造函数中没有参数命名位置,但此处提供的代码存在多个问题。它甚至不应该编译。为什么@lupz??是的,我已经添加了storeList.add(store);在主要活动中。。我在一个非常不同的课堂上使用这篇课文。。因此,我将如何获得storelist。get(position)position我无法获得r8??您必须获得要使用的对象,在这种情况下,storelist必须发送到类。您可以创建一个异步任务,从json获取项目并将其放入storelist中,然后将其返回到需要的地方。
mText.setText(storelist.get(index).getStoreName());