1.java代码
1.引入slidingmenu的库
* 2.定义activity继承SlidingFragmentActivity
* 3.将onCreate方法改为public的
* 4.加载slidingmenu的布局
package com.example.slidingmenudemo; import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity; import android.os.Bundle; /**
* 1.引入slidingmenu的库
* 2.定义activity继承SlidingFragmentActivity
* 3.将onCreate方法改为public的
* 4.加载slidingmenu的布局
* @author Administrator
*
*
*/
public class MainActivity extends SlidingFragmentActivity{ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//设置slidingmenu的布局
setBehindContentView(R.layout.left_menu);
//获取SlidingMenu对象
SlidingMenu slidingMenu = getSlidingMenu();
//设置第二侧边栏
slidingMenu.setSecondaryMenu(R.layout.right_menu);
//设置模式
slidingMenu.setMode(SlidingMenu.LEFT_RIGHT);
//设置触摸模式为全屏触摸
slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
//设置屏幕预留宽度
slidingMenu.setBehindOffset(200);
}
}
2.效果展示