Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm using RecyclerView as the base for my data list. i've implemented custom RecyclerView.Adapter which is based on ArraList. on fetching data from the internet the code that i'm running is:

public void addItems(List<Item> items){
    final int size = data.size();
    data.addAll(items);
    notifyItemRangeInserted(size, items.size());

Problem is that for after running this code i'm getting an autoscroll to the bottom of the list (last element is now visible)

Is there a way to disable this? couldn't find any similar questions.

relevant information: my adapter have 2 viewHolders - for position 0 it has a view (with viewType 0) and for the rest of list it has view with viewType 1

Thanks for your help!

thanks for your help. i tried it now, it's not working. also i'm not crazy about post insert solution because it can start scrolling a little before stopScroll is running. but anyhow it's not working /-: – royB Nov 22, 2014 at 17:21 strange, i had to explicitly call scrollToPosition to see my inew items, anyway did you try old school style notifyDataSetChanged()? – pskink Nov 22, 2014 at 17:38 there shouldn't be any penalty, only you will not be seeing that fancy insert animations if you have any – pskink Nov 22, 2014 at 17:59
public void addItems(List<QuestItem> items){    
    final int positionStart = data.size() + 1;
    data.addAll(items);
    notifyItemRangeInserted(positionStart, items.size());
                yeah well...as you can see i've added a comment which say so (from feb 23). thanks anyhow mate!
– royB
                May 26, 2015 at 10:21
                @localhost @royB As per the doc, positionStartis the position of the first item that was inserted. So shouldn't it be data.size() coz that is where the first item was inserted? :p
– Abhishek V
                Jul 28, 2015 at 12:45
                @localhost Thanks for the update. I am not sure though. let me know if it is otherwise :)
– Abhishek V
                Jul 28, 2015 at 12:51
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.