如何在Android中使用列表适配器显示矩阵游标? [英] How to display matrix cursor using list adapter in Android?

查看:247
本文介绍了如何在Android中使用列表适配器显示矩阵游标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图向游标添加行(使用矩阵游标完成),然后将游标传递到列表适配器(资源适配器)。列表适配器只需要一个游标。如何向列表适配器添加行?

I am trying to add row to the cursor (which is done with matrix cursor), then pass the cursor to the list adapter (resource adapter). The list adapter takes only a cursor. How do I add a row to the list adapter?

推荐答案

不向列表适配器添加行。您只需向矩阵游标添加一行,如下所示:

You don't add a row to the list adapter. You just add a row to the matrix cursor like this:

mx.newRow().add(0).add("value of second column").add("value of third column");
mx.newRow().add(1).add("value of second column").add("value of third column");

...

然后使用SimpleCursorAdapterconnect将MatrixCursor的ListAdapter

... etc. Then with a SimpleCursorAdapter you "connect" the MatrixCursor to the ListAdapter

这篇关于如何在Android中使用列表适配器显示矩阵游标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆