-
Notifications
You must be signed in to change notification settings - Fork 10
Description
作者你好:
我在项目中使用到你的框架遇到了个问题:
在全局设置 下拉样式:如下
JRecycleViewManager.getInstance().setLoadMoreView(new MyLoadMoreView(getBaseContext()));
因为 在项目中有不止一处地方用的了 上拉加载更多。。所以设置了统一样式。。以此为背景。
遇到这个异常:ViewHolder views must not be attached when created. Ensure that you are not passing 'true' to the attachToRoot parameter of LayoutInflater.inflate(..., boolean attachToRoot)
看源码发现: if (holder.itemView.getParent() != null) {
throw new IllegalStateException("ViewHolder views must not be attached when"
+ " created. Ensure that you are not passing 'true' to the attachToRoot"
+ " parameter of LayoutInflater.inflate(..., boolean attachToRoot)");
}
如果设置了全局MyLoadMoreView 作为ViewHoder 复用的时候会出现 第一次 不会有问题。。但是如果项目中 有二个地方已经以上用到的话: holder.itemView(MyLoadMoreView ).getParent 是值 是第一次 JRrecycleView 就这在里报出了异常。 我现在的做法是 在每个用到 jRecycleView 的时候。都
MyLoadMoreView myLoadMoreView = new MyLoadMoreView(context);
jRefreshAndLoadMoreAdapter.setLoadMoreView(myLoadMoreView);
都设置了这个新的 MyLoadMoewView 这样 解决了这个问题。。希望作者的库越来越好。