Recyclerview item根据条件,将item隐藏,onBindViewHolder
ViewGroup.LayoutParams layoutParams = linearLayout.getLayoutParams();
if (receptionHallBeanList.size()==0){
//隐藏item要把高度宽度设为0;
linearLayout.setVisibility(View.GONE);
layoutParams.height = 0;
layoutParams.width = 0;
}else {
//显示item要重新设置高度宽度;
linearLayout.setVisibility(View.VISIBLE);
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
}
linearLayout.setLayoutParams(layoutParams);
原文:https://blog.csdn.net/wuqingsen1/article/details/79698749