I'm trying to achieve like this Two recyclerview when i scroll down , the first recylcer to be scrolled too, how?
I implemented this but I'm facing issue like 0th element of second list in second view type is missing but when I post new item then that missing item visible at position 1 of adapter but then that new item in second list is missing until and unless I don't post any any item in second list
@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");
}