如何在 android 中从 setter getter 开始循环?
How to do a looping from setter getter in android?
我在 Array List 中创建了一个 setter getter,我想在我的 activity.
中显示它们
这是我的代码
response = (ProductListResponse) getIntent().getSerializableExtra("response");
category = response.getListCategory();
list = response.getListCategory().get(0).getProductList();
来自 get(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
}
我在 Array List 中创建了一个 setter getter,我想在我的 activity.
中显示它们这是我的代码
response = (ProductListResponse) getIntent().getSerializableExtra("response");
category = response.getListCategory();
list = response.getListCategory().get(0).getProductList();
来自 get(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
}