Simple use of SlidingMenu

Steps to use SlidingMenu:

1. Introduce the library file of SlidingMenu
2. Activity inherits SlidingFragmentActivity
3. Change the onCreate method to public
4. Call the api

 

Simple case:

 

 

package com.jxust.asus.slidingmenudemo;

import android.os.Bundle;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;

public class MainActivity extends SlidingFragmentActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView(R.layout.activity_main);

        setBehindContentView(R.layout.left_menu); // Set the left sidebar layout

        SlidingMenu slidingMenu = getSlidingMenu(); // get the sidebar object
        slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); // set full screen touch

        slidingMenu.setSecondaryMenu(R.layout.right_menu); // set the right sidebar
        slidingMenu.setMode(SlidingMenu.LEFT_RIGHT); // Set the display mode (both left and right)

        slidingMenu.setBehindOffset(100); // Set the width of the reserved screen



    }

}

 

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#f00">


</RelativeLayout>

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#0f0">

</RelativeLayout>

 

 

Effect:

 


 



 
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326646253&siteId=291194637