【问题标题】:Expandable ListView populate from local Sqlite database可扩展的 ListView 从本地 Sqlite 数据库填充
【发布时间】:2011-07-17 11:47:47
【问题描述】:

我正在寻找使用本地 sqlite 数据库的可扩展列表视图的教程。

到现在为止我的理解是这样的

private class MyTestList extends SimpleCursorTreeAdapter {

//The below is a constructor with 7 arguments with 3 for parent and 3 for child data ad layout

public MyTestList (Context ctx, Cursor groupCursor, int groupLayout,
        String[] groupFrom, int[] groupTo, int childLayout, String[] childFrom,
        int[] childTo) {
    super(ctx, groupCursor, groupLayout, groupLayout, groupFrom, groupTo, childLayout, childFrom, childTo);
}

我的问题是如何获取父光标和子光标,然后将它们相互链接。

有一个API叫

@Override
protected Cursor getChildrenCursor(final Cursor groupCursor) {

   //I suppose here I am passing the parent cursor and then retrieving the 
   //corresponding child cursor for the particular id ??

    NOT SURE HOW DO I FILL THIS, I THINK THIS WILL HAVE SOME STRING ARRAY WITH CHILD DATA
}

在此之后我应该将它与 ui 绑定,我该怎么做。找了很久没找到要找的东西。

【问题讨论】:

    标签: android sqlite expandablelistview


    【解决方案1】:

    就像您为组所做的那样,在您的 getChildrenCursor 中创建一个新游标,但使用 WHERE sql 语句来更具体地选择!有关代码示例,请参阅此 PAGE

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 2012-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-19
      相关资源
      最近更新 更多