Reputation: 55
I have some RecyclerView
item with invisible button and I would like to change all button visibility from Activity. Like this:
Please help me.
Upvotes: 2
Views: 5451
Reputation: 1750
Why don't you create a method inside your RecyclerAdapter which will activate the button when a certain action happens in the Activity. Let's say an activity named activateButtons
like this:
public void activateButtons(boolean activate) {
this.activate = activate;
notifyDataSetChanged(); //need to call it for the child views to be re-created with buttons.
}
Now, inside your onBindViewHolder
, do something like this:
if (activate) {
buttons.setVisibility(View.VISIBLE);
} else {
buttons.setVisibility(View.INVISIBLE);
}
and now, the final step, call the activateButtons
method from Activity on an action:
editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adapter.activateButtons(true);
}
});
Upvotes: 11