2

我有数组列表。我循环并获得 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);
4

1 回答 1

1

为了做到这一点,您应该对ArrayAdapter进行子分类。

在每个集合的末尾,您可以添加一个特殊的列表项,以便在 getView 方法中,只要该项目是那个特殊的,您就可以绘制分隔线。

于 2012-05-15T12:52:10.443 回答