我有ArrayList。我采取循环并获得2-3组的价值观。这次我得到了所有的价值,但在同一页面。我想在页面中分隔值集。我怎样才能分组。
这是我的代码:
ListAdapter mSchedule;
ListView list = (ListView) findViewById(R.id.orderlistview);
orderList = new ArrayList<Order>();
orderList = login.getOrderList();
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
for(int i=0;i<login.getOrdercount();i++)
{
map = new HashMap<String, String>();
map.put("Name", "Open");
map.put("Value", orderList.get(i).getOpen());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "Type");
map.put("Value", orderList.get(i).getType());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "Status");
map.put("Value", orderList.get(i).getStatus()); // mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "OrderNumber");
map.put("Value", orderList.get(i).getOrderNumber());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "OrderDate");
map.put("Value", orderList.get(i).getOrderDate());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "InvoiceNumber");
map.put("Value", orderList.get(i).getInvoiceNumber());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "InvoiceDate");
map.put("Value", orderList.get(i).getInvoiceDate());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "Days");
map.put("Value", orderList.get(i).getDays());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "ReferenceNumber1");
map.put("Value", orderList.get(i).getReferenceNumber1());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "ReferenceNumber2");
map.put("Value", orderList.get(i).getReferenceNumber2());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "LineNumber");
map.put("Value", orderList.get(i).getLineNumber());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "pid");
map.put("Value", orderList.get(i).getPid());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "MfgCode");
map.put("Value", orderList.get(i).getMfgCode());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "MfgName");
map.put("Value", orderList.get(i).getMfgName());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "PartNumber");
map.put("Value", orderList.get(i).getPartNumber());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "Description");
map.put("Value", orderList.get(i).getDescription());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "OrderQuantity");
map.put("Value", orderList.get(i).getOrderQuantity());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "ShipQuantity");
map.put("Value", orderList.get(i).getShipQuantity());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "BackorderQuantity");
map.put("Value", orderList.get(i).getBackorderQuantity());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "Eta");
map.put("Value", orderList.get(i).getEta());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "UnitPrice");
map.put("Value", orderList.get(i).getUnitPrice());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "UnitCoreCharge");
map.put("Value", orderList.get(i).getUnitCoreCharge());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "AuthorizationOrReferenceNumber");
map.put("Value", orderList.get(i).getAuthorizationOrReferenceNumber());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "OutboundTracking");
map.put("Value", orderList.get(i).getOutboundTracking());
mylist.add(map);
map = new HashMap<String, String>();
map.put("Name", "InboundTracking");
map.put("Value", orderList.get(i).getInboundTracking()+"\n");
mylist.add(map);
}
mSchedule = new SimpleAdapter(this, mylist, R.layout.order_list_item,
new String[] {"Name", "Value"}, new int[] {R.id.catagory, R.id.value});
list.setAdapter(mSchedule);
答案 0 :(得分:1)
您应该对ArrayAdapter进行细分,以便执行此操作。
在每个集合的末尾,您可以添加一个特殊的列表项,因此在getView方法中,只要该项是特殊项,就可以绘制分隔符。