我想拆分mProductType是一个列表,mRetailerid是另一个列表。我如何获取它?
public class RetailerNames implements Serializable{
private String mProductType;
private String mRetailerid;
public String getmProductType() {
return mProductType;
}
public void setmProductType(String mProductType) {
this.mProductType = mProductType;
}
public String getmRetailerid() {
return mRetailerid;
}
public void setmRetailerid(String mRetailerid) {
this.mRetailerid = mRetailerid;
}
@Override
public String toString() {
return mProductType + "," +
mRetailerid ;
}
我用下面的代码:
ArrayList<RetailerNames> retailerNamesList = (ArrayList<RetailerNames>) getIntent().getExtras().getSerializable("ProductsDetailsDescriptionPage");
System.out.println("The retailer details are"+" "+retailerNamesList);
现在我当前的输出是:
零售商的详细信息为[Krish,48,Danesh,47]
但是我想得到像[Krish,Danesh]这样的一个列表,而[48,47]是另外一个列表。我该怎么办?
请给我解决方案???
请给我一个想法,将数组列表拆分为单独的列表???
最佳答案
ArrayList list = new ArrayList();
Iterator<RetailerNames > retaileriterator = retailerNamesList.iterator();
while(retaileriterator.hasNext()){
id=retaileriterator .next().getmRetailerid();
System.out.println(id);
list.add(id);
}
System.out.println(list);