Create a cursor from hardcoded array instead of DB
https://stackoverflow.com/questions/18290864/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.
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.
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?
Thanks
Check out the MatrixCursor documentation. Check for instance this example.
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);
- ,@FaddishWorm Thanks for the post. Would you kindly tell me why am I getting "return type for the method is missing" error for startManagingCursor(matrixCursor). What what the solution to fix this. I am using API 19 with minimum api support 8. – Dexter Jun 1 '14 at 6:18
- @FaddishWorm: I solved the issue.It was a silly mistake. I was doing the call at the wrong place ie. not inside any method of the class. I managed to work it as getActivity().startManagingCursor(matrixCursor) as the class is a Fragment. – Dexter Jun 1 '14 at 6:31
- 2It would be nice for complete code. IE that layout is something you made??? I'm just testing libraries here and I need a cursor with strings – StarWind0 Oct 16 '15 at 11:24
maybe you can check MatrixCursor class that you can call addRow((Iterable<?> columnValues) or addRow(Object[] columnValues) hope that will help
use MatrixCursor, instead of addRow() which is not very handy, use builder method newRow()
Create a cursor from hardcoded array instead of DB的更多相关文章
- How To Create SharePoint 2010 Site Collection In Its Own DB
在SharePoint 2010中可以使用Management Shell 为新建的Site Collection 创建自己的DB. 在 Shell中执行如下命令: 1. $w = get-spweb ...
- create feature from text file
'''---------------------------------------------------------------------------------- Tool Name: Cre ...
- Multidimensional Array And an Array of Arrays
One is an array of arrays, and one is a 2d array. The former can be jagged, the latter is uniform. T ...
- OpenGL.Vertex Array Object (VAO).
OpenGL抛弃glEnable(),glColor(),glVertex(),glEnable()这一套流程的函数和管线以后,就需要一种新的方法来传递数据到Graphics Card来渲染几何体,我 ...
- python插入记录后取得主键id的方法(cursor.lastrowid和conn.insert_id())
#!/usr/bin/python # import MySQL module import MySQLdb # get user input name = raw_input("Pleas ...
- MongoDB - MongoDB CRUD Operations, Query Documents, Iterate a Cursor in the mongo Shell
The db.collection.find() method returns a cursor. To access the documents, you need to iterate the c ...
- 14.Iterate a Cursor in the mongo Shell-官方文档摘录
1 迭代游标 } ); while (myCursor.hasNext()) { print(tojson(myCursor.next())); } } ); myCursor.forEach(pri ...
- OpenGL.Vertex Array Object (VAO) [转]
http://www.cppblog.com/init/archive/2012/02/21/166098.html 一 OpenGL抛弃glEnable(),glColor(),glVertex() ...
- OpenGL.Vertex Array Object (VAO) 【转】
http://www.cppblog.com/init/archive/2012/02/21/166098.html 一 OpenGL抛弃glEnable(),glColor(),glVertex() ...
随机推荐
- Activiti7 流程变量(UEL-Value方式)
需求:请假天数大于3天走总经理审批,小于等于3天直接走人事 画图 因为IDEA不展示那个线上的东西,所以截屏自己写的,还有就是我感觉IDEA画图挺坑的,之前画了好几遍,一部署就报错,很奇怪 /** * ...
- Agumater 爬虫进度带上了百分比,消除了.0
- 单线程模式从网易下载A股叁仟捌佰支股票一年的交易数据耗时十四分钟
代码下载:https://files.cnblogs.com/files/xiandedanteng/StockDataDownloader20200305.rar 压缩包内包含股票代号文件,调整好日 ...
- tomcat-8.0.18 cluster 使用Redis共享Session 配置
事实证明 这位作者提在https://jingyan.baidu.com/article/ac6a9a5e10415f2b653eace8.html 最底下的http://pan.baidu.com/ ...
- Vue的优缺点
使用vue.js做开发快两年了,对vue的优缺点有一点自己的见解,跟大神比不了,但是面试基本够用 vue在国内能被广泛使用的首要原因是它是基于mvvm框架做开发的,mvvm是前端开发中一种很有影响力的 ...
- 《Java从入门到失业》第四章:类和对象(4.1):初识类和对象
4类和对象 在第一章曾经简单介绍过,在面向对象的世界里,一切事物皆对象,当解决一个问题的时候,我们先会考虑这个问题会涉及到哪些事物,然后把事物抽象成类,当时还画了一张图如下: 从本章开始,我们一点一点 ...
- W5300中文手册
如果链接没了就Q我吧1178875532 链接:https://pan.baidu.com/s/1HcNJN_T6QJCvPWymU1sFDQ 提取码:suBB
- SDL开发笔记(二):音频基础介绍、使用SDL播放音频
若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...
- NOIP2017 Day1 T1 小凯的疑惑
题目描述 小凯手中有两种面值的金币,两种面值均为正整数且彼此互素.每种金币小凯都有 无数个.在不找零的情况下,仅凭这两种金币,有些物品他是无法准确支付的.现在小凯想知道在无法准确支付的物品中,最贵的价 ...
- Badboy脚本录制工具
Badboy 目录 Badboy 1.Badboy安装 2.脚本的录制 1.Badboy安装 下载地址: http://www.badboy.com.au/download/index 安装其实傻瓜式 ...