I have one problem: when I add data to the list of arrays and then add them to the adapter after that, when I install it in the recycler view adapter, it automatically goes to the beginning, how can I prevent it, for example, I want to add data in virtual space, I also tried using -
runOnUiThread(new Runnable() {
public void run() {
innerAdapter.notifyDataSetChanged();
}
});
but it does not work. how can i solve it?
add code to scroll
if (isScrollUp) {
isEnable = true;
userChats.addAll(0, model.data);
innerChatAdapter.notifyDataSetChanged();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
nnerChatAdapter.notifyItemInserted(0);
recyclerView.smoothScrollToPosition(0);
}
}, 1);
}
source
share