SlidingMenu从jfeinstein10没有ActionBarSherlock例子例子、SlidingMenu、ActionBarSherlock

2023-09-12 01:59:23 作者:朕的心事,尔等岂懂

在过去的几天我一直在寻找如何使一个滑动菜单的例子。我发现很多方法,并决定jfeinstein10的解决方案可以很好地工作。但他的例子中,使用了我不想ActionBarSherlock,也是太复杂了我。

The last few days I've been searching for examples on how to make a sliding menu. I've found many ways and decided that jfeinstein10's solution should work best. But the example he has, uses ActionBarSherlock which I don't want, and is also too complicated for me.

我试图找到一个简单的例子,与Android的操作栏,但无法找到一个。谁能帮忙?

I tried to find a simple example with android's action Bar but couldn't find one. Could anyone help?

推荐答案

您必须扩展 SherlockActivity ,并创建一个 菜单。 XML 至极是你的菜单布局。

You have to extend SherlockActivity, and create a menu.xml wich is your menu layout.

然后,只需在你的的onCreate 方法添加这些几行。

Then just add those few lines in your onCreate method.

menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.menu);

这是我使用的是什么,现在和完美的作品。

That what i'm using right now and works perfectly.

如果你不想动作条,只是隐藏它是这样的:

If you don't want ActionBar, just hide it like this :

ActionBar myBar = getActionBar();
myBar.hide();