我在Array List中制作了一个setter getter,我想在我的活动中展示它们。
这是我的代码
response = (ProductListResponse) getIntent().getSerializableExtra("response");
category = response.getListCategory();
list = response.getListCategory().get(0).getProductList();
来自get(0)
,我的回复中只有索引0。那么,如何获得所有索引?谢谢
答案 0 :(得分:0)
你可以像这样使用for循环
for(int i=0;i<response.getListCategory().size();i++){
list = response.getListCategory().get(i).getProductList();; // use list
}
或者您可以使用foreach
for(datamodel data:response.getListCategory()){
list=data.getProductList(); //use the list
}