BArtWell
BArtWell

Reputation: 4044

How to use SlidingMenu with ViewPager?

I have ViewPager with content in MainActivity and I want to add SlidingMenu. I need that the SlidingMenu open only on the first page of ViewPager. I've found this example, but in this implementation it doesn't working well: it hard to open menu (SlidingMenu only react on narrow left side of screen) and working on every page (not only first). How to implement it properly?

Upvotes: 1

Views: 2621

Answers (1)

jsimon
jsimon

Reputation: 577

Regardless of your answer to my comment/question regarding your implementation of an ActionBar, you could modify the SlidingMenu source so that the margin for TOUCHMODE_MARGIN is larger. Open up CustomViewAbove.java in the com.slidingmenu.lib package and set the MARGIN_THRESHOLD int to something larger than 20. I used 80.

OPINION: I think jfeinstein should make that margin larger anyway or, at the very least, configurable.

If you don't want to do that, and you are implementing an ActionBar, you could simply use the ActionBar Home button and simply open the SlidingMenu that way. See https://stackoverflow.com/a/11409318/1165673 for reference.

To address the issue of only being available on the first page of the ViewPager, take a look at the setSlidingEnabled(bool b) function in SlidingMenu.java. You know which page you are on, so set sliding enabled based on your location.

Upvotes: 3

Related Questions