2012-05-24 73 views
0

我正在使用保存一切正常的本地sqlite數據庫。當我在expandableListView中打開一個組時,所有已經存儲在數據庫複選框中的複選框都被選中。當我編輯一個條目(我使用了AlertDialog)時,關閉該組,然後重新打開該組。該複選框不再被選中。我檢查了分貝,編輯被保存了。如果我轉到另一頁面並返回,一旦點擊該組,我再次檢查編輯的子項目。我在eclipse中使用了斷點,它似乎可以在數據庫中找到數據,但不會將該標記標記爲已選中。有任何想法嗎?expandablelistview複選框沒有保持選中

enter image description here

這是我第一次在組中,單擊(發動機)

enter image description here

現在我使用的是AlertDialog來更新條目

enter image description here

圖像

現在我關閉組

enter image description here

當我通過電池重新打開箱子不再被檢查。

這裏是當我打開一組

public void onGroupExpand(int groupPosition) 
{ 
    db= new InspectionRecordsTableDBAdapter(getBaseContext()); 
    db.open(); 
    int inspectionId = com.signalsetapp.inspectionchecklist.report 
      .returnStringID(); 
    String [] child=kids[groupPosition]; 
    ArrayList<Color> secList = new ArrayList<Color>(); 
    for(int i=0; i<child.length;i++) 
    { 
     try { 
      if (db.childFound(inspectionId, child[i])) 
       secList.add(new Color(child[i], true)); 
      else 
       secList.add(new Color(child[i], false)); 
     } catch (Exception e) { 
      secList.add(new Color(child[i], false)); 
      e.printStackTrace(); 
     } 

    } 

}

這裏是更新的代碼保存到數據庫的代碼。這不正確保存到數據庫

db.editRecords(
             primaryId, 
             com.signalsetapp.inspectionchecklist.report 
               .returnStringID(), 
             parent[groupPosition], 
             kids[groupPosition][childPosition], 
             input.getText().toString(), status); 
           onExpand=true; 

回答

2

你應該requery()後您將光標組保存到數據庫中,它應該重新生成列表視圖(或異步等同,因爲重新查詢已被棄用)。

相關問題