// 设置背景图
setBehindContentView(R.layout.frag1);
// 获得Left类对象
Fragment left = new Left();
// 开启事物,进行保存
getSupportFragmentManager().beginTransaction().replace(R.id.f1, left)
.commit();
menu = getSlidingMenu();
// 滑动模式
menu.setMode(SlidingMenu.LEFT);
// 边缘滑动
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
// 背景的宽度
menu.setShadowWidthRes(R.dimen.ShadowWidth);
// 设置菜单的宽度
menu.setBehindOffsetRes(R.dimen.BehindOff);
menu.setFadeDegree(0.4f);
// // 开启右侧侧滑
// menu.setSecondaryMenu(R.layout.frag_right);
//
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.right, new Right()).commit();
这里写代码片
在frag1.xml中
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/f1" >
</FrameLayout>
点击侧滑的属性
main_rentou.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
menu.showMenu();
menu.showSecondaryMenu();
}
});