In adapter class:
Boolean isVisible = false;
public CustomAdapter(boolean isVisible) {
this.isVisible= isVisible;
}
@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
...
if (isVisible){
//setVisibility(View.VISIBLE)
}else{
//setVisibility(View.INVISIBLE
}
}
public void updateVisibility(boolean newValue){
isVisible= newValue;
}
In Activity
where you want to update the value where the adapter is instantiated:
adapter.updateVisibility(false);
adapter.notifydataSetChanged();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…