如何单击滑动菜单中的项目。我正在使用活动而不是片段

时间:2015-01-31 06:42:58

标签: android slidingmenu

final SlidingMenu menu = new SlidingMenu(this);
        menu.setMode(SlidingMenu.RIGHT);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        //menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
        menu.setShadowWidth(5);
        menu.setFadeDegree(0.5f);
        menu.attachToActivity(HomePage.this, SlidingMenu.SLIDING_CONTENT);
        menu.setBehindWidth(200);
        menu.setMenu(R.layout.menu);


        menus.setOnClickListener(new OnClickListener() 
        {
            @SuppressLint("NewApi")
            @Override
            public void onClick(View arg0) 
            {
              menu.showMenu();
              //or 
              //menu.toggle();
            }
        });

请帮助我。

1 个答案:

答案 0 :(得分:0)

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
    long id) {
// TODO Auto-generated method stub

switch (position) {
case 0:
    Intent i=new Intent(this,your calss name);
    startactivity(i);
    break;

case 1:
    Intent i=new Intent(this,your calss name);
    startactivity(i);
    break;

case 2:
    Intent i=new Intent(this,your calss name);
    startactivity(i);
    break;

case 3:
    Intent i=new Intent(this,your calss name);
    startactivity(i);
    break;

default:
    break;
}

}