Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exact procedure to add "jfeinstein10 / SlidingMenu" in android project

I am totally new to android, i am trying to implement Sliding Menu having ListView with Swipe Gesture, by some searching i found that https://github.com/jfeinstein10/SlidingMenu is exactly what i want,

There are many questions related to this which are guiding how integrate this library with project, but none of them are for new person like me. also procedure given on github is not detailed, all i know is how to add .jar file but this .zip and other things are totally new for me

This is what i have done till yet;

  1. downloaded zip from above link
  2. Extracted that link to folder
  3. in Eclipse File->import->existing project into work-space..

Now it is showing me many error in package library.src.com.slidingmenu.lib.app

e.g

The declared package "com.slidingmenu.lib.app" does not match the expected package "library.src.com.slidingmenu.lib.app"

now i don't know what to do...

please somebody guide me with proper detailed procedure of how to integrate and use this library in project.

Thanks !

like image 687
john44 Avatar asked Dec 27 '12 15:12

john44


1 Answers

Well, spending 3 days with same problem I found the exact procedure for this thing. The guide on github is of-course not for entry level guys like us, also there is no such a "step-by-step tutorial" for this, so it took time.

Important: I didn't include "Sherlock ActionBar" library, because I want to keep it simple

  • First up all update your eclipse to latest ADT or best way you can download this ADT Bundle, and confirm that everything is running fine in new ADTBundle.

  • Download latest "zip for jfeinstein10 / SlidingMenu" from "gitHub", And extract it anywhere you want. After extraction it must have these files and folders inside.

Folder after extracting library

  • Now open your eclipse File -> Import -> Android -> Existing Android Code Into Workspace, Browse to your folder most probably "SlidingMenu-master" and you should see following

enter image description here

Hit Finish, If eclipse shows some error like Unable to resolve target then change your target through Right Click on project -> Properties -> Android and check any latest google API your SDK have.

  • Add Dependency, by right clicking on project -> properties -> android -> library -> add -> SlidingMenuActivity, and clear both projects.

  • Add new XML layout named as menu_frame in your res -> layout and put following in it Put Frame Layout and list view in it.

  • Also add a ListView in your mainActivity XML file.

  • Now it is time to create "Menu" write following code in your onCreate() after setContentView(R.layout.activity_main).

    SlidingMenu menu;
    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidth(5);
    menu.setFadeDegree(0.0f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setBehindWidth(200);
    menu.setMenu(R.layout.menu_frame);
    
  • At the lines it is showing error press ctrl+1 and import com.slidingmenu.lib.SlidingMenu;"

  • Run your project and you should see menu coming out from left side

  • Now the next task is to add adapter and listener for both of your ListViews (i.e for Main-screen and Menu).

For information about function used while creating Menu you can refer to example apps provided with library or google them, there is lot of info available.

Also thanks to "Jeremy Feinstein" for such a great library

like image 116
Saurabh Bayani Avatar answered Oct 14 '22 01:10

Saurabh Bayani