I'm using a recyclerView
which uses two types of Views : one is a HeaderView
and is at the first place of the list ( position == 0 ) and the second is the CommentView
.
What I want is onclick()
to remove the HeaderView
and replace it with another xml layout file I already have created.
Is it something I have to do inside the Adapter class ? I'm trying like this :
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// holder is instance of CommentItem
} else if (holder instanceof ViewHolderHeaderItem) {
final ViewHolderHeaderItem viewHolderHeaderItem = (ViewHolderHeaderItem) holder;
viewHolderHeaderItem.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
viewHolderHeaderItem.button.setVisibility(View.GONE);
}
});
I can set the visibility to GONE
but I don't see how I can inflate the layout .