SlidingMenu : Showing seconday menu on an event
android, slidingmenu
Solution
To show the second menu you can use:
getSlidingMenu().showSecondaryMenu(true);
The boolean parameter is the animation flag.
Problem
I am using the awesome library SlidingMenu by jfeinstein10. So, everything is is going just right but one thing. I am able to open the primary menu using the method `toggle()` in an event handler. But I also want the secondary menu to open on some event like button click. I did something like ``` SlidingMenu right = getSlidingmenu(); right.setSecondaryMenu(rightMenuView) ``` and was thinking of doing `right.toggle();` but the second statement above throws a NullPointerException. Edit : Posting onCreate ``` @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); leftMenuView = inflater.inflate(R.layout.left_menu, null, false); rightMenuView = inflater.inflate(R.layout.right_menu, null, false); customActionBarView = inflater.inflate(R.layout.custom_actionbar,null); findAllViews(); setFontAwesome(); ab = getSupportActionBar(); ab.setDisplayShowCustomEnabled(true); ab.setDisplayHomeAsUpEnabled(false); ab.setDisplayShowHomeEnabled(false); ab.setDisplayUseLogoEnabled(false); ab.setCustomView(R.layout.custom_actionbar); ivHome = (ImageView) findViewById(R.id.ab_home); ivHome.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d("TAG", "Tag"); toggle(); } }); leftSlidingMenu = getSlidingMenu(); leftSlidingMenu.setMode(SlidingMenu.LEFT_RIGHT); setBehindContentView(leftMenuView); leftSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); leftSlidingMenu.setBehindOffset(100); leftSlidingMenu.setFadeDegree(0.35f); rightSlidingMenu = getSlidingMenu(); rightSlidingMenu.setSecondaryMenu(rightMenuView); //NPE Here rightSlidingMenu.toggle(); } ``` Any idea how to open secondary menu on an event. Thank You