Slider Menu both side(right & left) in single Activity

user1381827 picture user1381827 · Apr 17, 2013 · Viewed 14.3k times · Source

I want slide Menu in both side(right & left) on single Activity

on Button click like below

enter image description here

i have tried this two library

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

and

https://github.com/SimonVT/android-menudrawer

but both are give slide Menu only right or left side.

Answer

Chris Dinon picture Chris Dinon · Apr 22, 2013

Yep Analizer has it right with setmode. Here's an example from jfeinstein10 library. Controlling the left menu with setMenu.. and the right with setSecondary...

https://github.com/jfeinstein10/SlidingMenu/blob/master/example/src/com/slidingmenu/example/LeftAndRightActivity.java

package com.slidingmenu.example;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;

import com.slidingmenu.example.fragments.ColorFragment;
import com.slidingmenu.lib.SlidingMenu;
import com.slidingmenu.lib.SlidingMenu.OnClosedListener;
import com.slidingmenu.lib.SlidingMenu.OnOpenedListener;


public class LeftAndRightActivity extends BaseActivity {

public LeftAndRightActivity() {
    super(R.string.left_and_right);
}

 @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);
    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    setContentView(R.layout.content_frame);
    getSupportFragmentManager()
    .beginTransaction()
    .replace(R.id.content_frame, new SampleListFragment())
    .commit();

    getSlidingMenu().setSecondaryMenu(R.layout.menu_frame_two);
    getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);
    getSupportFragmentManager()
    .beginTransaction()
    .replace(R.id.menu_frame_two, new SampleListFragment())
    .commit();
 }

}

Make sure to get a clean and updated copy of the library as well. Just in case.