2011-08-23 26 views
0

我填補這樣的列表視圖給出如下需要獲得基於行的列表視圖中的彩色有條件

cursor = manifest_helper.GetDeliveriesAgainstManifest(pkManifest); 
cursor.moveToFirst(); 

for (int i = 0; i < cursor.getCount(); i++) { 

    map = new HashMap<String, String>(); 
    map.put("Deliv_Address", 
      cursor.getString(cursor.getColumnIndex("Address"))); 
    map.put("Deliv_Time", 
      cursor.getString(cursor.getColumnIndex("Time"))); 
    map.put("Deliv_Order", 
      cursor.getString(cursor.getColumnIndex("DeliveryOrder"))); 
    map.put("Deliv_IsCustomerPickup", 
      cursor.getString(cursor.getColumnIndex("IsCustomerPickup"))); 
    map.put("Deliv_FKDeliveryStatus", 
      cursor.getString(cursor.getColumnIndex("FKDeliveryStatus"))); 
    map.put("Deliv_PKDelivery", 
      cursor.getString(cursor.getColumnIndex("PKDelivery"))); 
    alist.add(map); 
    cursor.moveToNext(); 

} 
sd = new SimpleAdapter(this, alist, R.layout.deliveries_list_row, 
     new String[] { "Deliv_Address", "Deliv_Time", 
       "Deliv_Order", "Deliv_IsCustomerPickup", 
       "Deliv_FKDeliveryStatus", "Deliv_PKDelivery" }, 
     new int[] { R.id.tv_Deliv_Address, R.id.tv_Deliv_Time, 
       R.id.tv_Deliv_Order, 
       R.id.tv_Deliv_IsCustomerPickup, 
       R.id.tv_Deliv_FKDeliveryStatus, 
       R.id.tv_Deliv_PKDelivery }); 
//selectedAdapter = new SelectedAdapter(this, 0, alist); 
//selectedAdapter.setNotifyOnChange(true); 

ListDeliveries.setAdapter(sd); 

的問題是,現場Deliv_IsCustomerPickup具有值在每行CO

我想區分每個CO與行不同的顏色,即一個C與有紅色和一個與O需要有藍色

+0

接受某些問題的答案。 – darma

回答

0

使用ViewBinder.setViewValue()放置你的條件。從這裏你擁有對列表UI的完全訪問權限。

您setViewValue一些僞代碼:

if(your_condition) { 
    SomeLayout layout = (SomeLayout) view.getParent(); 
    layout.setBackground(...); 
} 
return false; // let the system put values in the View objects.