如何使SlidingMenu仅幻灯片内容,而不是动作条 [英] How to make SlidingMenu only slide content and not the ActionBar
问题描述
我在我的应用程序使用 SlidingMenu 与ActionBarSherlock和我已经实现的方式是通过使它扩展了 SlidingFragmentActivity
(类似于他们在<一个表现方式 BaseActivity
href=\"https://github.com/jfeinstein10/SlidingMenu/blob/master/example/src/com/jeremyfeinstein/slidingmenu/example/BaseActivity.java\"相对=nofollow>例如)。在我的应用程序的每个其他活动扩展了该BaseActivity。
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.
但目前当我在App,包括动作条幻灯片整个活动左边滑动。我只想要的内容滑动。所以在看文档,我计算过,增加这个应该这样做: menu.attachToActivity(这一点,SlidingMenu.SLIDING_CONTENT);
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:这SlidingMenu似乎已经连接
这里是BaseActivity的OnCreate功能 -
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);
}
我应该做的 attachToActivity
别的地方?
推荐答案
我最终被从基地活性删除此解决它 - sm.attachToActivity(这一点,SlidingMenu.SLIDING_WINDOW);
I eventually solved it by removing this from the Base activity - sm.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
和刚刚添加该所有继承活动的onCreate:
and just adding this to the onCreate of all the inherited Activities:
setSlidingActionBarEnabled(假);
我想这是从继承的长线未来(myActivity - > BaseActivity ---> SlidingFragmentActivity - > SherlockFragmentActivity)
I guess this is coming from a long line of inheritance (myActivity --> BaseActivity ---> SlidingFragmentActivity --> SherlockFragmentActivity)
这篇关于如何使SlidingMenu仅幻灯片内容,而不是动作条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!