在我的 Android 应用程序中,我使用 Sqlite 数据库来存储来自服务器的数据。我正在使用 ContentProvider 和 ContentResolver 从数据库访问数据并使用 CursorAdapter 将数据绑定到 ListView。一旦数据插入DataBase,就会通知CursorAdapter 更新ListView。此外,每当我滚动 ListView 时,我都会从 DataBase 表中获取新数据,并且 ListView 将被更新。但是一旦我到达表行的末尾,我需要直接从服务器获取数据,而不是存储到数据库中并在 ListView 中更新它。现在,当我使用接受 Cursor 数据的 CursorAdapter 时,如何绑定一组不是来自数据库的新数据?是否可以在不从数据库获取数据的情况下创建游标数据并使用 ContentProvider 中的 ChangeCursor() 方法来更新 ListView?如果没有,是否有任何其他方法可以实现相同的效果?
问问题
4519 次
1 回答
10
Is is possible to create Cursor data without getting data from the DataBase and use ChangeCursor() method in the ContentAdapter to update the ListView?
Yes, you can create cursor using MatrixCursor. If you will have to merge MatrixCursor with database Cursor use MergeCursor.
于 2013-04-07T09:05:16.737 回答