从硬编码数组而不是DB创建游标

Fad*_*orm 40 android cursor

我正在尝试为我正在编写的小游戏应用程序制作拖放列表.

列表中有6个条目.但是我添加的库需要一个与DB对话的Cursor对象.这对我的情况来说太过分了.

有没有办法创建一个基于基于内存的数据结构的Cursor对象,如数组?有没有办法可以使用硬编码数组作为我的光标?

谢谢

Tri*_*mon 52

查看MatrixCursor 文档.例如检查这个例子.

String[] columns = new String[] { "_id", "item", "description" };

MatrixCursor matrixCursor= new MatrixCursor(columns);
startManagingCursor(matrixCursor);

matrixCursor.addRow(new Object[] { 1, "Item A", "...." });

SimpleCursorAdapter adapter = 
        new SimpleCursorAdapter(this, R.layout.layout_row, matrixCursor, ...);

setListAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

  • 完整的代码会很好.IE布局是你做的事情??? 我只是在这里测试库,我需要一个带字符串的游标 (2认同)