我想GridLayoutManager 保存我的RecyclerView的状态,但是当调用 onSaveInstanceState() 的时总是返回同一个对象.我用方法"findFirstVisibleItemPosition"时,它总是返回 -1.
RecyclerView 有适配器,适配器有一些元素,我可以滚动它们!我不知道为什么无法获得完全初始化和工作组件的项目位置!请帮忙!
这是我的代码:
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(BUNDLE_MOVIES_RECYCLER_VIEW_STATE, mMoviesRecyclerView.getLayoutManager().onSaveInstanceState());
outState.putInt(BUNDLE_SEGMENT_POSITION, mSelectedFilterPosition);
outState.putSerializable(BUNDLE_NOW_PLAYING_MOVIE, mNowPlayingMovie);
outState.putSerializable(BUNDLE_SEGMENTED_MOVIES, mSegmentMovies);
}