Reputation: 21
I have ArrayList. I taking a loop and getting values in 2-3 sets. This time I am getting all values, but in same page. I want to seperate the sets of values in pages. How can I divide the sets.
This is my code:
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);
Upvotes: 2
Views: 425
Reputation: 1887
You should subclassify ArrayAdapter in order to do this.
At the end of each set you could add an special list item so on the getView method you could draw the divider whenever the item is that special one.
Upvotes: 1