I’m some kind of new working with RecyclerView
and I have noticed lately on one of the tutorials that they use RecyclerView.NO_POSITION
with smoothScrollToPosition()
.
Here's the example:
private RecyclerView mRecyclerView;
private int mPosition = RecyclerView.NO_POSITION;
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (mPosition == RecyclerView.NO_POSITION) mPosition = 0;
mRecyclerView.smoothScrollToPosition(mPosition);
}
But I don’t know exactly what NO_POSITION
or this smoothScrollToPosition()
actually do? Also I tried to search official doc, other essays or checking other guys questions here. Unfortunately, none helped me.
Can anyone explain what their purpose/why do we need to use them?
NO_POSITION is a constant whose value is -1, it basically means that when don't you find the position of the model in the underlying dataset the return value of this method will be NO_POSITION.
smoothScrollToPostion(value) tells your view to go to that particular position in the recyclerView.