When the red button is pressed, the orange button appears.
When the red button is pressed again, the orange button disappears.
(Basically a toggle)
This happens with notifyDataSetChanged()
and different ItemViewTypes
.
Two questions:
OnClickListener
every time, and de-register it too?RecyclerView
through notifyDataSetChanged()
and I just have to add it every time?RecyclerViewAdapter
?onCreateViewHolder
code:
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
RecyclerView.ViewHolder holder;
View view;
if (viewType == ADD_FOOTER_ITEM) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_sa_add_footer_item, parent, false);
holder = new AddFooterViewHolder(view);
} else if (viewType == INPUT_ITEM) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_sa_input_item, parent, false);
holder = new InputViewHolder(view);
} else {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_sa_item, parent, false);
holder = new CustomViewHolder(view, this);
}
return holder;
}
recycler_view_sa_add_footer_item.xml
is basically just a FrameLayout with an ImageButton and some visual stuff in it. The question is about that one ImageButton
.
onCreateViewHolder
method.