Ari*_*Roy 4 android listview view android-recyclerview
我想在单击 RecyclerView某项后禁用全部单击,并假设在500英里后再次启用它。
这样做的目的只是为了防止快速单击 RecyclerView项目中的项目。例如,某人可能会快速点击3个项目,而所有这些项目都会被触发。
我已经尝试过了setEnabled(false),setClickable(false)但是它们都不能单独使用或一起使用时不能工作。
可能是您必须禁用RecyclerView的所有子级。您可以这样做:
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
其中参数view是您的RecyclerView。
| 归档时间: |
|
| 查看次数: |
2626 次 |
| 最近记录: |