1

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?

BArtWell
  • 4,176
  • 10
  • 63
  • 106

1 Answers1

3

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.

Community
  • 1
  • 1
jsimon
  • 577
  • 6
  • 17
  • Thank you for your answer! But now I find example from jfeinstein in ViewPagerActivity.java and it is working fine. Why I didn't find it before - I don't know. – BArtWell Dec 17 '12 at 20:49
  • No problem, glad my input could be of use. :D Take care. – jsimon Dec 17 '12 at 21:03