Disable second click in Navigationdrawer

Asked

Viewed 71 times

1

I’m developing an app, which contains a menu drawer, but I have a multitoque, that is, when the user selects an item, and quickly selects again, it keeps the drawer aberto.

I would like, that when the user selects an item, the drawer close, and ignore the second click.

the event I’m dealing with today is like this

exp_list_fragments.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {

                if (groupPosition == 3 && childPosition > 0) {
                    switch (childPosition) {
                        case 1:
                            logoutApplication(false);
                            break;
                        case 2:
                            DialogSendEmail d = new DialogSendEmail(Activity_Main.this);
                            d.show();
                            break;
                        case 3:
                            rt.questionExitSystem();
                            break;
                    }
                } else {
                    Child_Fragments child_fragment = group_fragments.get(groupPosition).getFragments().get(childPosition);
                    controller.setActionBarTitle(child_fragment.getTitle(), child_fragment.getIcone());
                    supportInvalidateOptionsMenu();
                    getSupportFragmentManager().beginTransaction().replace(R.id.layout_drawer_content,
                            child_fragment.getFragment()).commit();
                }
                setFragmentSelection(groupPosition, childPosition);
                layout_drawer.closeDrawer(layout_drawer_drawer);
                return false;
            }
        });
    }

1 answer

0

Hello,

Try at the end of the method onChildClick change return false; for return true;. This makes the OS no longer treat this click captured in any next method of the listener hierarchy...just as its method already "handled" the event, you do not want more future treatments...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.