Я использую базу данных Room для извлечения данных из базы данных. Recyclerview Я хочу прокрутить до определенной позиции в Recyclerview.
Я уже пробовал list.setNestedScrollingEnabled (true)
StationListRepository stationListRepositoryOnlyActive = new StationListRepository (getApplicationContext ());
stationListRepositoryOnlyActive.getActiveStationList (). Наблюдать (это, новый Наблюдатель> () {
@Override
public void onChanged (List OnlyActivestations) {
Log.d ("OnlyActivestations", "" + OnlyActivestations.size ());
assert OnlyActivestations! = null;
if (OnlyActivestations.size ()> 0 || FinalList.size ()> 0) {
if (FinalList! = null && FinalList.size ()> 0) {
OnlyActivestations = sortList (OnlyActivestations);
FinalList.addAll (OnlyActivestations);
} else {
OnlyActivestations = sortList(OnlyActivestations);
FinalList = OnlyActivestations;
}
Log.d("FinalListSizeActive",""+FinalList.size());
detailsAdapter = new db_stationListAdapter(context, FinalList);
//recyclerView.setNestedScrollingEnabled(true);
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL);
staggeredGridLayoutManager.scrollToPosition(10);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
recyclerView.setAdapter(detailsAdapter);
detailsAdapter.notifyDataSetChanged();
runOnUiThread(new Runnable() {
@Override
public void run() {
// stopLoading();
stopAnimation();
}
});
}
}
});
Я, кроме окна рециркуляции, для автоматической прокрутки в положение 10