cundong / headerandfooterrecyclerview Goto Github PK
View Code? Open in Web Editor NEWA RecyclerView solution, support addHeaderView、addFooterView
License: Apache License 2.0
A RecyclerView solution, support addHeaderView、addFooterView
License: Apache License 2.0
例子不错,不知道大神发现例子中瀑布流存在一个问题,还是没法用到实际项目中去:
瀑布流加载下一页成功后再返回到顶部,会明显的看到item移动。有解决办法吗?
没有gradle引用?没有gradle引用?
like this :
public void addHeaderView(View header) {
if (header == null) {
throw new RuntimeException("header is null");
}
header.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
,ViewGroup.LayoutParams.WRAP_CONTENT));
mHeaderViews.add(header);
this.notifyDataSetChanged();
加上这个解决方案就更加完整了。
外部添加scollerview就无法实现下拉加载了
手动给head的view设置OnClickListener,然后点击head布局,不会走回调
view in headerview , setAnimation()
RecyclerView.Adapter.notifyDataSetChanged()(not HeaderAndFooterRecyclerViewAdapter)
------------> Animation disappear
LinearLayout set to Horizontal View is not working properly
HeaderAndFooterAdapter中oncreateViewHolder中的viewType怎么来的,我自己的viewtype与这个有什么关系
如题,添加了两个header,每个header里都是一个RecyclerView,发现第一个header没问题,第二个header的宽度和主RecyclerView的item宽度一致了。
代码可以设置避免这样的bug,但是总感觉不是很好,不够完美!
` public static LoadingFooter.State getFooterViewState(RecyclerView recyclerView) {
RecyclerView.Adapter outerAdapter = recyclerView.getAdapter();
if (outerAdapter != null && outerAdapter instanceof HeaderAndFooterRecyclerViewAdapter) {
if (((HeaderAndFooterRecyclerViewAdapter) outerAdapter).getFooterViewsCount() > 0) {
LoadingFooter footerView = (LoadingFooter) ((HeaderAndFooterRecyclerViewAdapter) outerAdapter).getFooterView();
return footerView.getState();
}
}
return LoadingFooter.State.Normal;
}`
你好,当我添加了一个不是LoadingFooter类型的FootView时,loadNextPage时 调用 LoadingFooter footerView = (LoadingFooter) ((HeaderAndFooterRecyclerViewAdapter) 强制转换会出问题。
不能添加多个header和footer
能否加上左右删除的功能,跟QQ类似的。谢谢
LinearLayoutManager lm = new LinearLayoutManager(this);
lm.setOrientation(LinearLayoutManager.HORIZONTAL);
mRecyclerView.setLayoutManager(lm);
如果设置为横向 ,中能加载一页数据。
if ((visibleItemCount > 0 && currentScrollState == RecyclerView.SCROLL_STATE_IDLE && (lastVisibleItemPosition) >= totalItemCount - 1)) {
onLoadNextPage(recyclerView);
}
//经常触发多次导致数据重复
下拉刷新回调接口是什么
RT,方便android studio里引入。
将要,但是还没有滑动到底部的最后一item的时候,会自动滑动到底部,并且显示正在加载的footerview,非常不友好的体验。有没有什么解决方案?
u can remove the footer.then add a new footer .u can changed the state. no matter u use nofifyitemchanged or not the state can not be changed. why?
我要实现瀑布流第二个item 距离同一排item偏下的样式,后面的布局以此中间向下。我添加了这个
public class SpaceItemDecoration extends RecyclerView.ItemDecoration{
private int space;
public SpaceItemDecoration(int space) {
this.space = space;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.left=space;
outRect.right=space;
outRect.bottom=space;
if(parent.getChildAdapterPosition(view)==1){
outRect.top=250;
}
}
上拉滚动时候new footerView的时候出现UI重排 界面变成一样齐的。滚到顶部在滚下来才会正常排列。不知道是什么原因感觉是recycleView重用机制导致找不到 position =1的位置导致重排?
内部Adapter获取到viewType是wrapadapter赋的
对于比较复杂的headerview 向上滑动显示headerview的时候会出现抖动 ,请问你这边遇到过吗?比如headerview长达3屏
layoutManager = new GridLayoutManager(getContext(), 3);
cateCommodityList.setLayoutManager(layoutManager);
adapter = new CategoryAdapter(getContext(), categories);
// cateCommodityList.setAdapter(adapter);
mHeaderAndFooterRecyclerViewAdapter = new HeaderAndFooterRecyclerViewAdapter(adapter);
cateCommodityList.setAdapter(mHeaderAndFooterRecyclerViewAdapter);
View headerView = LayoutInflater.from(getContext()).inflate(R.layout.layout_cate_header, null);
//add a HeaderView
RecyclerViewUtils.setHeaderView(cateCommodityList, headerView);
结果 header 并不能出现在顶部,而是一个普通的item..
目前还没找到解决的办法..
使用了headerAndFooter后,局部刷新失效
我在项目中添加了两个heardview ,没有添加 footview 的时候 会出现 问题 是,添加的第二个 Header 同时会出现在 footView 上 . 我的解决办法是 将 TYPE_FOOTER_VIEW = Integer.MIN_VALUE + 1;更改为 Integer.MIN_VALUE / 2;
java.lang.IllegalArgumentException: Called attach on a child which is not detached: ViewHolder
瀑布流第一次上拉加载更多后,当前item,位置发生了变化,往回滑倒顶部出现布局重排(出现重排动画)
RecyclerViewStateUtils.setFooterViewState(RealDataActivity.this, mRecyclerView, REQUEST_COUNT, LoadingFooter.State.NetWorkError, mFooterClick);
//当网络错误重新点击或加载
private View.OnClickListener mFooterClick = new View.OnClickListener() {
@OverRide
public void onClick(View v) {
Log.d(TAG, "onClick: ");
RecyclerViewStateUtils.setFooterViewState(RealDataActivity.this, mRecyclerView, REQUEST_COUNT, LoadingFooter.State.Loading, null);
mPresenter.onPageShowRealData(param);
}
};
瀑布流布局第一次加载更多时footer在最左边没居中,第二次加载更多就好了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.