SlidingMenu导入后怎么使用

来源:互联网 发布:淘宝智能版多少钱 编辑:程序博客网 时间:2024/04/29 09:14

使用步骤

    - 1. 引入SlidingMenu的库文件 上一篇有介绍    - http://blog.csdn.net/duandonghui/article/details/51853249    - 2. Activity继承SlidingFragmentActivity    - 3. 将onCreate方法改为public

- 调用api

        setBehindContentView(R.layout.left_menu);// 设置侧边栏布局        SlidingMenu slidingMenu = getSlidingMenu();// 获取侧边栏对象        slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);// 设置全屏触摸        slidingMenu.setSecondaryMenu(R.layout.right_menu);// 设置右侧边栏        slidingMenu.setMode(SlidingMenu.LEFT_RIGHT);// 设置展现模式        slidingMenu.setBehindOffset(100);// 设置预留屏幕的宽度

需要一个侧边栏的布局文件 left_menu.xml

    <?xml version="1.0" encoding="utf-8"?>    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"        android:id="@+id/fl_left_menu"        android:layout_width="match_parent"        android:layout_height="match_parent" >    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="这是侧边栏"/>    </FrameLayout>  
0 0