Chanven / CommonPullToRefresh

Android widget with pull to refresh for all the views,and support loadMore for ListView , RecyclerView, GridView and SwipeRefreshLayout.
Apache License 2.0
1.07k stars 303 forks source link

有关RecycleView 的问题 #13

Open SunShRui opened 8 years ago

SunShRui commented 8 years ago

您好: 下面是有关于RecycleView的问题 作者在RecyclerAdapterWithHF中对adapter添加header 和footer mAdapter.addHeader(mHeader); mAdapter.addFooter(mHeader); 当LinearLayoutManager 为 StaggeredGridLayoutManager时列数大于1 addHeader 和 addFooter 变为Item,布局错位,看了代码后发现,作者是在把view 当做adapter 的一个Item 给添加进去的,这样当为StaggeredGridLayoutManager 或GridView ,列数大于1,添加的头部和底部会变形,还有加载更多 同样 public void addHeader(View header) { if (!mHeaders.contains(header)) { mHeaders.add(header); // animate notifyItemInserted(mHeaders.size() - 1); } }

      mAdapter = new RecyclerAdapterWithHF(adapter);

// mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); // mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(4, // StaggeredGridLayoutManager.VERTICAL)); mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));