Download Two Ride - Left and Right Sliding Menu Example Code Android

Implement Right and Left Side Sliding Menu Android Example          
        
                  In Android Basically with the help of drawer we can implement the one side slide menu as the following image



How Implement right slide menu in android  -  There is no any pre-defined property or class of android to implement the right slide menu. For that purpose we have to use the some additional or external library to implement it.

           To Implement the we need to set the library slider.jar in our project after that using little bit code we can easily implement it.

Step by Step Implement Right Side and Left Side Sliding menu -  

1. First of all download the slider.jar from the Link

2. Create the two separate xml file for right and left slide menu.

leftmenu.xml ( Left Slide Menu XML file )

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/textView1"
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Left Menu"
        android:textColor="#ffffff" />
</LinearLayout>

rightmenu.xml (Right Slide Menu XML File )
<?xml version="1.0" encoding="utf-8"?>
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/textView1"
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Right Menu"
        android:textColor="#ffffff" />
</LinearLayout>
3. After create these two different files use the following code to to implement it

package com.example.slide_menu;

 

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

 

import com.dheeruapps.SimpleSideDrawer;

 

public class MainActivity extends Activity {

    SimpleSideDrawer slide_me;

    Button left_button, right_button;

 

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        slide_me = new SimpleSideDrawer(this);

        slide_me.setLeftBehindContentView(R.layout.left_menu);

        slide_me.setRightBehindContentView(R.layout.right_menu);

 

        left_button = (Button) findViewById(R.id.left_buton);

        right_button = (Button) findViewById(R.id.right_buton);

        left_button.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                slide_me.toggleLeftDrawer();

            }

        });

        right_button.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                slide_me.toggleRightDrawer();

            }

        });

    }

}

4. Execute -  After Successfully Implement it you will get the following output 


Main Screen - 
Left Menu-


Right Menu -

You Can also download the source code of the application from the following link - 


0 comments:

Post a Comment

My Instagram