Open ethpran opened 9 years ago
Are you calling setHasStableIds(true) on your adapter? Otherwise mHasStableIds will still be false.
If your adapter always has stable ids, you can simply set it from the constructor:
public CursorRecyclerViewAdapter(Cursor cursor) {
mCursor = cursor;
mDataValid = cursor != null;
mRowIdColumn = mDataValid ? mCursor.getColumnIndex("_id") : -1;
mDataSetObserver = new NotifyingDataSetObserver();
if (mCursor != null) {
mCursor.registerDataSetObserver(mDataSetObserver);
}
setHasStableIds(true);
}
You do not actually have to override setHasStableIds()
at all.
I'm not positive if I'm doing something incorrect here. My CursorAdapter uses the primary column id as the adapter id and I override setHasStableIds like so:
...
@Override public long getItemId(int position) { if (mDataValid && mCursor != null && mCursor.moveToPosition(position)) { return mCursor.getLong(mRowIdColumn); } return 0; }
However, I keep getting the above error message when trying to implement your library. Is there some kind of problem with using a CursorAdapter as the underlying adapter for the RecyclerView? Perhaps I'm implementing this incorrectly? Thanks for your attention