Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

菜单子项 设置 点击无效 #318

Open
Boyka-SS opened this issue Feb 26, 2022 · 1 comment
Open

菜单子项 设置 点击无效 #318

Boyka-SS opened this issue Feb 26, 2022 · 1 comment

Comments

@Boyka-SS
Copy link

可不可以,菜单子项设置 成 不可点击 状态

@luqiming666
Copy link

luqiming666 commented May 8, 2022

可以是可以的。参见我fork后修改的版本:
https://github.com/luqiming666/SwipeRecyclerView

我增加了侧滑菜单展开/收起的回调通知:OnItemMenuStateListener,然后在收到菜单展开通知时这么处理:

 public void onMenuState(RecyclerView.ViewHolder viewHolder, int menuState) {
                MainAdapter.ViewHolder vh = (MainAdapter.ViewHolder) viewHolder;
                if (menuState == OPEN) {
                    vh.setHiddenView(true);

                    // 尝试修改菜单项的状态
                    SwipeMenuLayout menuLayout = (SwipeMenuLayout) vh.itemView;
                    if (menuLayout.hasRightMenu()) {
                        SwipeMenuView rightMenuView = (SwipeMenuView) menuLayout.getChildAt(2);
                        View view1 = rightMenuView.getChildAt(0); // 第一个menu item
                        view1.setEnabled(false);
                    }

                    Toast.makeText(DefineActivity.this, "菜单已展开,位置:" + viewHolder.getAdapterPosition(), Toast.LENGTH_SHORT).show();
                } else {
                    vh.setHiddenView(false);
                    Toast.makeText(DefineActivity.this, "菜单已收起,位置:" + viewHolder.getAdapterPosition(), Toast.LENGTH_SHORT).show();
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants