Java 如何在android中从setter-getter执行循环?

Java 如何在android中从setter-getter执行循环?,java,android,loops,getter-setter,Java,Android,Loops,Getter Setter,我在数组列表中创建了一个setter getter,我想在我的活动中显示它们 这是我的密码 response = (ProductListResponse) getIntent().getSerializableExtra("response"); category = response.getListCategory(); list = response.getListCategory().get(0).getProductList(); 从get(0)

我在数组列表中创建了一个setter getter,我想在我的活动中显示它们

这是我的密码

   response = (ProductListResponse) getIntent().getSerializableExtra("response");
        category = response.getListCategory();
        list = response.getListCategory().get(0).getProductList();

get(0)
,我只从我的响应中得到了索引0。那么,如何获得all索引呢?谢谢你

你可以用for loop来实现这样的效果

for(int i=0;i<response.getListCategory().size();i++){
list = response.getListCategory().get(i).getProductList();; // use list
}

不过,如果您没有得到解决方案,请在这里发布您的json响应。我将从json响应打印arraylist。
for(datamodel data:response.getListCategory()){
list=data.getProductList(); //use the list
}