【问题标题】:expandablelistview checkboxes not staying checkedexpandablelistview 复选框未保持选中状态
【发布时间】:2012-05-24 16:32:23
【问题描述】:

我正在使用本地 sqlite 数据库,它可以正确保存所有内容。当我在 expandableListView 中打开一个组时,所有已存储在数据库中的复选框都被选中。当我编辑一个条目时(我使用了一个 AlertDialog),关闭该组,然后重新打开该组。该复选框不再被选中。我检查了数据库并保存了编辑。如果我转到另一个页面并返回,一旦我单击该组,我编辑的子项目将再次被选中。我在eclipse中使用了断点,它似乎在db中找到了数据,但没有将框标记为选中。有什么想法吗?

这是我第一次点击组(引擎)时的图像

现在我正在使用 AlertDialog 来更新条目

现在我关闭群组

当我通过电池重新打开该框时,不再选中。

这是我开群时的代码

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;

【问题讨论】:

    标签: android checkbox expandablelistview


    【解决方案1】:

    您应该在保存到数据库后requery()您的组光标,它应该重新生成列表视图(或异步等效,因为重新查询已被弃用)。

    【讨论】:

      猜你喜欢
      • 2016-06-19
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 2013-06-08
      • 2011-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多