How to use Sliding Menu with ActionBar Sherlock?

会有一股神秘感。 提交于 2019-12-03 06:25:25

问题


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?

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.


回答1:


Edit library SliderMenu to extents SherlockActivity

public class SlidingActivity extends SherlockActivity implements SlidingActivityBase {



回答2:


Do as it says in 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);
    }
    



回答3:


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

Heres a screenshot to make it more clear:



来源:https://stackoverflow.com/questions/12071399/how-to-use-sliding-menu-with-actionbar-sherlock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!