I have code like this
public static class MyViewHolder extends RecyclerView.ViewHolder {
@InjectView(R.id.text)
TextView label;
public MyViewHolder(View itemView) {
super(itemView);
ButterKnife.inject(this, itemView);
}
public void hide(boolean hide) {
label.setVisibility(hide ? View.GONE : View.VISIBLE);
}
}
which maps to a single row in a RecyclerView
. R.id.text
is in fact the root view of the layout that gets inflated and passed in to the constructor here.
I'm using the default implementation of LinearLayoutManager
.
In bindViewHolder
, I call hide(true)
on an instance of MyViewHolder
, but instead of collapsing the row as expected, the row becomes invisible, maintaining its height and position in the RecyclerView
. Has anyone else run into this issue?
How do you hide items in a RecyclerView?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…