Android 如何在 ActionBar Sherlock 中使用滑动菜单?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12071399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:38:33  来源:igfitidea点击:

How to use Sliding Menu with ActionBar Sherlock?

androidactionbarsherlockandroid-sliding

提问by aman.nepid

I am trying to use a sliding menu in my existing project where action bar Sherlock is used. But I am unable to do that. If you can give me a simple demo or tutorial to show me how to do so, that would be great? Do we have to use the fragments for the sliding menu?

我正在尝试在使用操作栏 Sherlock 的现有项目中使用滑动菜单。但我无法做到这一点。如果你能给我一个简单的演示或教程来告诉我如何做到这一点,那就太好了?我们是否必须将片段用于滑动菜单?

Update:

更新:

How do I change the Activity when the user clicks on an item of the Sliding Menu list?

当用户单击滑动菜单列表的项目时,如何更改活动?

Is there a demo? please help.

有演示吗?请帮忙。

回答by sonida

Edit library SliderMenuto extents SherlockActivity

将库编辑SliderMenu到范围SherlockActivity

public class SlidingActivity extends SherlockActivity implements SlidingActivityBase {

回答by aman.nepid

Do as it says in https://github.com/jfeinstein10/SlidingMenu

按照https://github.com/jfeinstein10/SlidingMenu 中的说明进行操作

  1. Create your sliding layout.
  2. In onCreate:

    setBehindContentView(R.layout.slide_menu);
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
    getSlidingMenu().setBehindScrollScale(0.25f);
    
  3. And in the activity:

    @Override
        public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            toggle();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    
  1. 创建您的滑动布局。
  2. 在 onCreate 中:

    setBehindContentView(R.layout.slide_menu);
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
    getSlidingMenu().setBehindScrollScale(0.25f);
    
  3. 在活动中:

    @Override
        public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            toggle();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    

回答by Chris Smith

I did not find it very clear from the instructions on the (SlidingMenu GitGub)

我没有从 ( SlidingMenu GitGub)上的说明中发现它很清楚

Heres a screenshot to make it more clear: enter image description here

这是一个屏幕截图,以使其更清楚: 在此处输入图片说明