I am using SlidingMenu with ActionBarSherlock in my app and the way I have implemented it is by making a BaseActivity
which extends SlidingFragmentActivity
( similar to the way they showed in the example ). Every other activity in my app extends this BaseActivity.
But currently, when I slide from the left in the App, the entire activity including the ActionBar slides. I only want the content to slide. So looking at the docs, I figured that adding this should do it: menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
But I get an error for that line -
java.lang.IllegalStateException: This SlidingMenu appears to already be attached
Here's the onCreate function of the BaseActivity -
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(mTitleRes);
// set the Behind View
setBehindContentView(R.layout.menu_frame);
if (savedInstanceState == null) {
FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
mFrag = new MenuListFragment();
t.replace(R.id.menu_frame, mFrag);
t.commit();
} else {
mFrag = (ListFragment)this.getSupportFragmentManager().findFragmentById(R.id.menu_frame);
}
// customize the SlidingMenu
SlidingMenu sm = getSlidingMenu();
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
sm.setFadeDegree(0.35f);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
// **** This following line causes the error *****
sm.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Should I be doing the attachToActivity
somewhere else?