dmitry-zaitsev/AndroidSideMenu

Back key handle

Closed this issue · 2 comments

First I thank for this helpful library. I'm already using it and it saved my time.

I think it's common that when the menu pane is visible, pressing the back button should close it, instead of closing the Activity itself (the default behavior). I checked and didn't see this. Does AndroidSlideMenu support it and we have to enable it somehow, or not?

Anyhow, I used this code to get the mentioned behavior:

    @Override
    public void onBackPressed()
    {
        SlideHolder sh = (SlideHolder)findViewById(R.id.slide_holder);
        if (sh.isOpened())
            sh.close();
        else
            super.onBackPressed();
    }

@mousamk yeah, I just wanted to answer you with exactly the same solution :)