web服务中的Android Endless Recyclerview重新加载到第一个位置

时间:2016-02-12 07:34:25

标签: android web-services endlessscroll

我的程序中有一个无尽的回收者视图。我引用了这个链接

http://android-pratap.blogspot.in/2015/01/endless-recyclerview-onscrolllistener.html

没有网络服务它可以正常工作。但是在第二次调用webservice

时重新加载到之前的位置
 mAdapter.setOnLoadMoreListener(new OnLoadMoreListener() {

                    @Override
                    public void onLoadMore() {
                        System.out.println("LOAD MORE");
                        details.add(null);
                        mAdapter.notifyItemInserted(details.size() - 1);
                        System.out.println("Exception Loadmore calling");
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                               System.out.println("Exception 2");
                                details.remove(details.size() - 1);
                                System.out.println("Exception 3");
                              mAdapter.notifyItemRemoved(details.size());
                                System.out.println("Exception 4");
                            page++;
                                System.out.println("Exception 5");
                                if (page < totalPages) {
                                    System.out.println("Exception 6");
                                    try {
                                        System.out.println("Exception 7");
                                        volleydata();
                                        System.out.println("Exception 8");
                                           mAdapter.notifyItemInserted(details.size());
                                        System.out.println("Exception 9");
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }
                                    System.out.println("Exception 10");

                                    mAdapter.notifyDataSetChanged();

                                }
                            }
                        }, 1000);
                        System.out.println("load");
                    }
                });

0 个答案:

没有答案