0

我尝试按照本教程为片段中的列表视图实现 CursorLoader。在列表视图中滚动时一切都很好(即使是快速滚动,也很流畅),除了我第一次切换到这个片段时,光标加载器加载有点慢。有谁知道如何加快速度?这是我的尝试:

public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {

   String[] projection = { DatabaseHandler.UserTable.id, DatabaseHandler.UserTable.name };

   cursorLoader = new CursorLoader(this, DatabaseAccessUtility.CONTENT_URI, projection, null, null, null);
   return cursorLoader;

}

 public void onLoadFinished(Loader<Cursor> loader,Cursor cursor) {
   if(mAdapter!=null && cursor!=null)
    mAdapter.swapCursor(cursor);

 public void onLoaderReset(Loader<Cursor> arg0) {
if(mAdapter!=null)
    mAdapter.swapCursor(null);
}
4

0 回答 0