SlidingMenu(jfeinstein10)在Sherlock Activity中的错误

时间:2015-01-20 13:12:30

标签: android view actionbarsherlock slidingmenu

我正在尝试向MainActivity添加滑动菜单。我导入了SlidingMenu和ActionBarSherlock并尝试应用于我的代码。当我在4.2.2平板电脑中运行我的应用程序时,我的应用程序看起来很好并且运行正但是当我尝试在4.1.1,4.4.4和5.0.0的虚拟设备中运行它时,滑动动作有效,但视图不会发生。这是代码。

MainActivity(简体);

public class MainActivityMain extends SherlockActivity {
    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    //SlidingMenu
    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.slidingmenu_shadow_width);
    menu.setShadowDrawable(R.drawable.graytrans);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(getSlidingView());
    }

        //View of slidingMenu
    public View getSlidingView(){
    View view;
    LayoutInflater inflater = (LayoutInflater) this
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.slidingmenulayout, null);
    ListView lv = (ListView) view.findViewById(R.id.listViewOfSlidingMenu);
    lv.setAdapter(new ListAdapter(this,monthNames));
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if(position == 12){
                title.setText(monthNames[position]);
                listView.setAdapter(new PersonAdapter(mContext, people));
                menu.toggle();
            }
            else{
            title.setText(monthNames[position]);
            listView.setAdapter(new PersonAdapter(mContext,    getThisMonthsPeople(people, position+1)));
            menu.toggle();
            }
        }
    });
    ImageButton close = (ImageButton) view.findViewById(R.id.backarrow);
    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            menu.toggle();
        }
    });
    return view;
    }
}

它在我的平板电脑中的外观(4.2.2): How it looks in my tablet(4.2.2): 它在虚拟设备中的外观(5.0.0): enter image description here

如您所见,在虚拟设备中,滑动菜单位于右侧。但它应该在左边。而且没有任何观点。根据这种情况你有什么看法?提前谢谢。

0 个答案:

没有答案