15

I have a problem (seriously, I do not know how to do it :D) with the implementation of SlidingMenu library (from Jeremy Feinstein... link is dowm) for Android. Is there anyone who can help me with implementation process? I am beginning Android programmer, so sometimes I need help :)

Library - https://github.com/jfeinstein10/SlidingMenu

Gaurav Agarwal
  • 18,754
  • 29
  • 105
  • 166
Štěpán Víteček
  • 317
  • 2
  • 4
  • 15

3 Answers3

24

I used Feinstein library myself and decided to create example app with flexible and reusable implementation as much as I could think.

Please check the source code at GitHub.

Download app directly to the device to try.

Here sliding menu, as it's content, uses list fragment. I made two approaches. One, when list data is filled with data loaded from XML file. Second, when data is filled from separate class.

I added many comments to catch the idea more easily. I hope it will be helpful! ;)

mmBs
  • 8,421
  • 6
  • 38
  • 46
  • @Andrius Baruckis Hey, I used your sample project, its simple and good :) But I am facing a problem in the source code. The following import is not found: import com.slidingmenu.lib.SlidingMenu; – berserk Dec 10 '13 at 14:11
  • 1
    Ok fixed this one xD But having error at getSlidingMenu() Error is: The method getSlidingMenu() from the type SlidingMenuInitialiser refers to the missing type SlidingMenu – berserk Dec 10 '13 at 14:14
  • Ok fixed all bugs XD I just removed ur import statement and changed to original Feinstein library :D – berserk Dec 10 '13 at 14:15
10

Create an Activity which extends SlidingActivity, create a Fragment for your menu and in the method onCreate add this :

FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setId(ID_MENUFRAME);
setBehindContentView(frameLayout);
FragmentTransaction ft = getFragmentManager().beginTransaction();
MenuFragment menuFragment = new MenuFragment();
ft.replace(ID_MENUFRAME, menuFragment);
ft.commit();

where ID_MENUFRAME is an int which is not an id present in your layout (I set it to 1).
Then, if you want to open or close the menu, call :

getSlidingMenu().toggle();

And you use your activity like any other activity.
Note that you will have to customize your SlidingMenu programmatically. For example :

sm.setBehindOffsetRes(R.dimen.slidingMenu_behindOffset);
sm.setShadowWidthRes(R.dimen.slidingMenu_shadowWidth);
sm.setShadowDrawable(R.drawable.slidingmenu_shadow);
yDelouis
  • 2,094
  • 17
  • 18
5

There's an example project in there: https://github.com/jfeinstein10/SlidingMenu/tree/master/example

Just import it to Eclipse.

AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277