创建一个从硬codeD阵列,而不是DB游标 [英] Create a cursor from hardcoded array instead of DB
问题描述
我试图使一个小游戏程序,我正在写一拖和下拉列表。
I am trying to make a drag-and-drop list for a little game app I am writing.
有在列表6项。不过,我增加了库要求会谈到一个数据库一个Cursor对象。这是矫枉过正了我的情况。
There are 6 entries in the list. However the library I added required a Cursor object that talks to a DB. This is overkill for my situation.
有没有一种方法来创建基于像阵列基于内存的数据结构的Cursor对象?有没有一种方法,我可以用一个硬codeD数组作为我的光标?
Is there a way to create a Cursor object that is based on a memory-based data structure like an array? Is there a way I can used a hard-coded array as my Cursor?
感谢
推荐答案
退房 MatrixCursor
的documentation 。检查实例<一href="http://stackoverflow.com/questions/1882156/using-matrixcursor-and-simplecursoradapter-in-a-listview-with-text-and-images">this例如。
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);
这篇关于创建一个从硬codeD阵列,而不是DB游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!