Comments (10)
我去把它demo拿来试试
from pinnedsectionitemdecoration.
问题知道了,他实际设的是包装后的adapter,所以adapter instanceof PinnedHeaderNotifyer就是false
@Override public void setAdapter(Adapter adapter) { mWrapAdapter = new WrapAdapter(adapter); super.setAdapter(mWrapAdapter); adapter.registerAdapterDataObserver(mDataObserver); mDataObserver.onChanged(); }
from pinnedsectionitemdecoration.
好的 我再试试 谢谢
from pinnedsectionitemdecoration.
我改了代码,不报错了,结果还是兼容不了
from pinnedsectionitemdecoration.
嗯 我还是不用那个库了
from pinnedsectionitemdecoration.
新的版本去掉那个实现PinnedHeaderNotifyer接口了,该用构建的时候就传递头部对应的type,所以包装后的adapter也是可以用了,只是这个库的type会在你原adapter的基础下加个260多的值(我打印出来看到的),所以传值的时候原值+263即可实现粘性头部了 @13588823551
from pinnedsectionitemdecoration.
你好,新版本出现错误。
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.oushangfeng.pinnedsectionitemdecoration.entity.ClickBounds.getLeft()' on a null object reference
at com.oushangfeng.pinnedsectionitemdecoration.callback.OnItemTouchListener$GestureListener.onDown(OnItemTouchListener.java:130)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:559)
at com.oushangfeng.pinnedsectionitemdecoration.callback.OnItemTouchListener.onInterceptTouchEvent(OnItemTouchListener.java:84)
at android.support.v7.widget.RecyclerView.dispatchOnItemTouchIntercept(RecyclerView.java:2394)
at android.support.v7.widget.RecyclerView.onInterceptTouchEvent(RecyclerView.java:2440)
我是在你的demo上改的,StockActivity,我把
mHeaderItemDecoration = new PinnedHeaderItemDecoration.Builder(StockEntity.StockInfo.TYPE_HEADER)
.setDividerId(R.drawable.divider).enableDivider(true)
.setClickIds(R.id.iv_more,R.id.fl,R.id.checkbox).disableHeaderClick(true)
.setHeaderClickListener(clickAdapter).create();
这段代码改为
mHeaderItemDecoration = new PinnedHeaderItemDecoration.Builder(StockEntity.StockInfo.TYPE_HEADER)
.disableHeaderClick(true).create();
就会报错。
mBoundsArray这个对象是空的。
是不是HeaderItemDecoration必须绑定一个ClickAdapter?
from pinnedsectionitemdecoration.
我看看,待会给你答复 @13588823551
from pinnedsectionitemdecoration.
更新下即可,我的失误 @13588823551
from pinnedsectionitemdecoration.
刚才的问题解决了,你的demo可以跑通,但是我自己写的会报错...
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getLeft()' on a null object reference
at com.oushangfeng.pinnedsectionitemdecoration.PinnedHeaderItemDecoration.createPinnedHeader(PinnedHeaderItemDecoration.java:376)
at com.oushangfeng.pinnedsectionitemdecoration.PinnedHeaderItemDecoration.onDraw(PinnedHeaderItemDecoration.java:143)
at android.support.v7.widget.RecyclerView.onDraw(RecyclerView.java:3608)
这是我写的Decoration部分
OnHeaderClickAdapter clickAdapter = new OnHeaderClickAdapter() {
@Override
public void onHeaderClick(View view, int id, int position) {
switch (id) {
case R.id.item_tag:
ToastUtil.show(getActivity(), "click tag " + mAdapter.getData().get(position).getLabel());
break;
case R.id.item_data:
ToastUtil.show(getActivity(), "click " + mAdapter.getData().get(position).getName());
break;
}
}
};
PinnedHeaderItemDecoration decoration = new PinnedHeaderItemDecoration.Builder(ItemEntity.TYPE_HEADER)
.setClickIds(R.id.item_tag, R.id.item_data).setHeaderClickListener(clickAdapter).create();
mRecyclerView.addItemDecoration(decoration);
mAdapter = new MyAdapter(null);
mRecyclerView.setAdapter(mAdapter);
adapter是异步加载数据的。
from pinnedsectionitemdecoration.
Related Issues (20)
- bug in android support 28.0.0 HOT 4
- 吸顶tab切换 HOT 2
- 每次刷新数据的时候,上面的悬停view会挡住第一行,请问下怎么解决呢 HOT 1
- 配合XRecycleView使用会出现粘性头部和实际数据位置不符的问题
- 设置divider比较宽的时候,最左边第一张图片宽度被压缩,比同行的另外几张窄
- 与databinding 使用 文字不显示
- Header根布局必须使用FrameLayout否则设置背景色无效
- java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.widget.TextView
- 设置吸顶decoration,出现如图问题 HOT 1
- ItemDecoration标签点击事件异常(标签布局中部分子View点击事件不生效)
- ![image](https://user-images.githubusercontent.com/6427399/60393522-45f34700-9b49-11e9-821b-94409c372b17.png)
- 点击事件回调方法onHeaderClick(View view, int id, int position)中,第一个参数(被点击的View)可能并不是真实标签中的view, 点击事件中刷新标签UI可能不生效 HOT 1
- 滑动的时候 Rv的srcollbar 的高度会一直变化,一会长一会短 这个有办法处理吗?
- 怎么设置分割线的大小 HOT 1
- RecyclerView的clipToPadding="false"属性不生效
- 怎样实现增量插入更新到对应的组内
- 当悬浮view有网络图片时 加载空白 可能是还没有加载完成时,已经好创建了view
- 自适应宽高的瀑布流
- jcenter 即将于五月一日关停. 可以将库上传到 jitpack.io 之类的地方吗 HOT 1
- header item layout 中 有自定义View 悬浮时不显示
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinnedsectionitemdecoration.