我的rV有小问题。 我正在一个项目中,我不必在RecyclerView上显示所有位置,这是我的问题,如何使它们不可见。 我正在尝试VIEW.GONE,但它在布局之间留出间隔。 就是这样
holder.relativeLayoutPartnera.setVisibility(View.GONE); 得分也一样。
有什么想法吗?
public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) {
PartnersModel currentItem = partnerList.get(position);
holder.wariantNagrody.setOrientation(LinearLayout.VERTICAL);
holder.partnerName.setText(currentItem.getName());
if(currentItem.getIlosc_pkt().equals("") || currentItem.getIlosc_pkt().isEmpty()){
holder.textView_ownedPoints.setText("0");
}else{
holder.textView_ownedPoints.setText(currentItem.getIlosc_pkt());
}
nid.clear();
descOfPromotion.clear();
pointsForPromotion.clear();
for(int i=0; i < currentItem.listOfReward.size(); i++) {
if (currentItem.listOfReward.get(i).getBid().equals(currentItem.bid)) {
if((Integer.parseInt(currentItem.listOfReward.get(i).getPoints()) <= Integer.parseInt(String.valueOf(holder.textView_ownedPoints.getText())))){
if(!nid.contains(currentItem.listOfReward.get(i).getBid())){
nid.add(currentItem.listOfReward.get(i).getBid());
descOfPromotion.add(currentItem.listOfReward.get(i).getName());
pointsForPromotion.add(currentItem.listOfReward.get(i).getPoints());
}
}
}
}
if(nid.size() > 0){
Log.v("parser", "IS OKEY.");
} else{
Log.v("parser", "ERROR. DO NOT DISPLAY THIS POSITION");
holder.params.height = 0;
holder.params.width = 0;
holder.params.setMargins(0,0,0,0);
holder.layout.setLayoutParams(holder.params);
}
Picasso.get()
.load(StartActivity.partners_layout_url + currentItem.getPic())
.placeholder(R.drawable.error_image)
.fit()
.transform(new picasso_rounded_corners(50, 0, picasso_rounded_corners.CornerType.TOP))
.into(holder.partnerLogo);
if (currentItem.getIlosc_pkt().isEmpty() || Integer.parseInt(currentItem.getIlosc_pkt()) == 0) {
holder.textView_ownedPoints.setText("0");
} else {
holder.textView_ownedPoints.setText(currentItem.getIlosc_pkt());
}
holder.wariantNagrody.removeAllViews();
for (int i = 0; i < descOfPromotion.size(); i++) {
View child1 = LayoutInflater.from(mContext).inflate(R.layout.view_layout_extended_description_partner, null);
TextView promotionPoints = child1.findViewById(R.id.textView_viewLayoutExtendedDiscPartner_points);
TextView promotionDesc = child1.findViewById(R.id.textView_viewLayoutExtendedDiscPartner_desc);
promotionPoints.setText(pointsForPromotion.get(i));
promotionDesc.setText(descOfPromotion.get(i));
holder.wariantNagrody.addView(child1);
}
}