Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jfeinstein10 SlidingMenu: how to stop sliding menu

Tags:

android

Shortly, I have a slide menu and I want it should only show menu when user press on menu button instead of sliding from left -> right (or right to left).
My menu config look like:

    SlidingMenu sm = getSlidingMenu();
    sm.setMode(SlidingMenu.LEFT); // or sm.setMode(SlidingMenu.RIGHT);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindScrollScale(0.25f);
    sm.setFadeDegree(0.25f);    

I don't find any configs to prevent sliding menu. Please could you tell me how can I do it?
Thanks in advance.

like image 675
ductran Avatar asked Oct 08 '13 16:10

ductran


1 Answers

This will disable swiping:

getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);

And this will make the menu toggle on clicking on the app icon in the action bar

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();

    if (itemId == android.R.id.home) {
        getSlidingMenu().toggle();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
like image 171
Nachi Avatar answered Nov 06 '22 00:11

Nachi