recyclerview每次刷新数据后都会定位在第一条

2018-02-27  本文已影响0人  芒鞋胜马

找了半天才发现自己蠢的不行

刷新数据不能每次都new adapter 并且不能 每次都setadapter

if (mHomeBean.getBallList().size() > 0) {
if (page == 1 && !isRefresh) {
//第一次需要new出Adapter
adapter = new LivingHomeRecyclerAdapter(activity, mLivingList);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(activity);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(adapter);
}
// mLivingList.addAll(mHomeBean.getBallList());
List<LivingHomeBean.BallListBean> list = new ArrayList<>();
list = mHomeBean.getBallList();
adapter.setList(list);

                    }
上一篇下一篇

猜你喜欢

热点阅读