我正在努力实现这样的目标当我向下滚动时有两个回收器视图,第一个回收器也被滚动,怎么样? https://stackoverflow.com/questions/45688512/two-recyclerview-when-i-scroll-down-the-first-recylcer-to-be-scrolled-too-how/45688735#45688735
我实现了这个,但我遇到了第二个视图类型中第二个列表的第 0 个元素丢失的问题,但是当我发布新项目时,该缺少的项目在适配器的位置 1 处可见,但第二个列表中的新项目丢失,直到且除非我没有在第二个列表中发布任何项目
@Override
public int getItemViewType(int position) {
if (isPositionPopularRt(position)) {
return TYPE_POPULAR_RT;
}
return TYPE_POST_LIST;
}
private boolean isPositionPopularRt(int position) {
return position == 0;
}
@NotNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup viewGroup, int viewType) {
mUserModel = SharedPrefsUtils.getObject(AppConstants.PrefKey.KEY_USER_MODEL, UserModel.class);
if (viewType == TYPE_POST_LIST) {
//inflate your layout and pass it to view holder
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.view_for_cell, viewGroup, false);
CustomViewHolder tempViewHolder = new CustomViewHolder(view);
view.setTag(tempViewHolder);
return tempViewHolder;
} else if (viewType == TYPE_POPULAR_RT) {
//inflate your layout and pass it to view holder
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.popular_rt_recycler_view, viewGroup, false);
return new MyViewHolderPopularRt(v);
}
throw new RuntimeException("there is no type that matches the type " + viewType + " + make sure your using types correctly");
}
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)