I'm suffering with one problem that when I add data to array list and then add it into adapter after that when I set it to recycler view adapter it jumps to top automatically how can I prevent it like I want to add data in virtual space I also tried with use of -
runOnUiThread(new Runnable() {
public void run() {
innerAdapter.notifyDataSetChanged();
}
});
but it not working. how can I solve it?
add some code for scrolling up
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);
}
Hello if you want to scroll down after add data to adapter.Add below method after notifyDataSetChanged() called.
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mRecyclerView.smoothScrollToPosition(new_data_size);
}
}, 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With