2012-05-11 5 views
2

나는 ArrayList를 가지고있다. 나는 루프를 가져 와서 2-3 세트의 값을 얻는다. 이번에는 모든 값을 얻고 있지만 같은 페이지에 있습니다. 페이지의 값 집합을 분리하고 싶습니다. 어떻게 세트를 나눌 수 있습니까?Listview의 목록 항목 사이에 줄을 추가하는 방법은 무엇입니까?

  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); 

답변

1

당신은이 작업을 수행하기 위해 ArrayAdapter을 subclassify해야

내 코드입니다.

각 세트의 끝에서 특별한 목록 항목을 추가 할 수 있으므로 getView 메소드에서 항목이 특별한 항목 일 때마다 구분선을 그릴 수 있습니다.

관련 문제