小编shi*_*gss的帖子

具有非db内容提供程序的Matrixcursor

我有一个内容提供程序,它返回query()方法的MatrixCursor.

Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
{
   MatrixCursor cursor = new MatrixCursor(new String[]{"a","b"});
   cursor.addRow(new Object[]{"a1","b1"});
   return cursor;
}
Run Code Online (Sandbox Code Playgroud)

在LoaderManager的onLoadFinished()回调方法中,我使用游标数据来更新文本视图.

public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    cursor.moveToFirst();
    String text = (String) textView.getText();
    while (!cursor.isAfterLast()) {
        text += cursor.getString(1);
        cursor.moveToNext();
    }
    textView.setText(text);

}
Run Code Online (Sandbox Code Playgroud)

现在的问题是,如何向MatrixCursor添加一个新行,它将立即通知对LoaderManager的回调方法的更改?

我希望,我已经明确了这个问题.提前致谢.

android android-contentprovider matrixcursor android-loadermanager

5
推荐指数
1
解决办法
1598
查看次数