Reputation: 15625
I want to disable clicks on the entire RecyclerView
once an item of it is clicked and enable it back again after suppose 500 milis.
The idea is just to prevent multiple rapid clicks on the items of the RecyclerView items. For example, some one may quickly tap on 3 items and all of them will get triggered.
I have tried setEnabled(false)
and setClickable(false)
but both of them doesn't work alone or when used together.
Upvotes: 4
Views: 3219
Reputation: 539
May be you have to disable all the children of the RecyclerView. You can do it like this:
private static void setViewAndChildrenEnabled(View view, boolean enabled) {
view.setEnabled(enabled);
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
setViewAndChildrenDisabled(child, enabled);
}
}
}
Where parameter view
is your RecyclerView.
Upvotes: 5