Simple library which enable you to add a drawer(slide-out) navigation to your android application

Overview

SimpleSideDrawer is an android library to add a drawer navigation into your android application. This library has high affinity with other libraries like ActionBarSherlock or etc.

#Easy to add your app a side menu Demo image01 Demo image02

###Step1: Add the library Add the jar library to your application project

###Step2: Set up the side menu Add the 2 lines under the onCreate method in an Activity you want to add the side menu.

protected void onCreate(Bundle data) {
	super.onCreate( data );
	setContentView( R.layout.main );
	
	mSlidingMenu = new SimpleSideDrawer( this );
	mSlidingMenu.setLeftBehindContentView( R.layout.behind_menu_left );
}

The behind_menu.xml is the side menu layout. You can add it by calling setBehindeContentView method. That it you have to do for adding the side menu. If you want to handle the widget on the side menu, you just call findViewById method as usual.

Need the right-side?

mSlidingMenu.setRightBehindContentView( R.layout.behind_menu_right );

###Step3: Open/Close the side menu You can easy open/close the side menu.

mSlidingMenu.toggleDrawer();

Of course, a user can close the side menu by dragging the above view.

More info

See my slide share in which I describe the detail of this library. http://www.slideshare.net/adamrocker/simple-side-drawer2

#Directory

  • SimpleSideDrawer: The library source code
  • demo: The demo android projects which uses this library
  • library: .jar file for easy to use
  • doc: The document of this library

#Lisence Copyright 2013, adamrocker ( http://www.adamrocker.com ).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • java.lang.ClassCastException: android.view.View cannot be cast to android.view.ViewGroup

    java.lang.ClassCastException: android.view.View cannot be cast to android.view.ViewGroup

    Hi, I am using simple-side-drawer with fragment, first time its render contents but after pop fragment, when I again render that fragment that I have pop, its give me exception. you can see that exception below

    `

    syncDispatchLocalHits timed out: java.util.concurrent.TimeoutException E/UncaughtException: java.lang.ClassCastException: android.view.View cannot be cast to android.view.ViewGroup at com.navdrawer.SimpleSideDrawer.(SimpleSideDrawer.java:240) at com.navdrawer.SimpleSideDrawer.(SimpleSideDrawer.java:193) at browseactivitiesreeboks.BrowseActivitiesByCatagoryActivity.setUpViews(BrowseActivitiesByCatagoryActivity.java:127) at browseactivitiesreeboks.BrowseActivitiesByCatagoryActivity.onCreateView(BrowseActivitiesByCatagoryActivity.java:104) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

    throwable java.lang.ClassCastException: android.view.View cannot be cast to android.view.ViewGroup E/AndroidRuntime: FATAL EXCEPTION: main Process: com.istar.reebok.reeboks, PID: 2011 java.lang.ClassCastException: android.view.View cannot be cast to android.view.ViewGroup at com.navdrawer.SimpleSideDrawer.(SimpleSideDrawer.java:240) at com.navdrawer.SimpleSideDrawer.(SimpleSideDrawer.java:193) at browseactivitiesreeboks.BrowseActivitiesByCatagoryActivity.setUpViews(BrowseActivitiesByCatagoryActivity.java:127) at browseactivitiesreeboks.BrowseActivitiesByCatagoryActivity.onCreateView(BrowseActivitiesByCatagoryActivity.java:104) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)`

    how to handle that exception, please help me

    Regards Munir Ahmad

    opened by MunirAhmad 5
  • java.lang.IllegalStateException on setBehindContentView

    java.lang.IllegalStateException on setBehindContentView

    Following exception was thrown when mAboveView.addView(above) called on setBehindContentView() method.

    01-27 20:55:25.222: W/System.err(5964): Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. 01-27 20:55:25.226: W/System.err(5964): at android.view.ViewGroup.addViewInner(ViewGroup.java:3337) 01-27 20:55:25.226: W/System.err(5964): at android.view.ViewGroup.addView(ViewGroup.java:3208) 01-27 20:55:25.250: W/System.err(5964): at android.view.ViewGroup.addView(ViewGroup.java:3165) 01-27 20:55:25.250: W/System.err(5964): at android.view.ViewGroup.addView(ViewGroup.java:3145) 01-27 20:55:25.250: W/System.err(5964): at com.navdrawer.SimpleSideDrawer.setBehindContentView(SimpleSideDrawer.java:137)

    This error does not occur on demo example application. I don't know why. Anyway, it seems that the modification of SimpleSideDrawer.java on commit e066e1eea7 is not needed because mAboveView was completely prepared on constructor. It works well if I erase the modification.

    Thank you for your useful OSS.

    bug 
    opened by aTakeshiKominato 4
  • I want to creat the menu like app of path on ios . left menu and right menu

    I want to creat the menu like app of path on ios . left menu and right menu

    Hey

    First of all, thanks for sharing your app menu drawer implementation.

    OK. I want to creat the menu like app of path on ios . that have two menu for left and right in the mainactiviy in the theam time.

    But in your code,This is currently not possible, you just have only one for left menu.

    how to do that ?

    Thanks.

    enhancement 
    opened by liufsd 4
  • Drawer items' onclick methods does not called

    Drawer items' onclick methods does not called

    I succesfully added the drawer.

    But the problem is drwer items dont respond to onclicks.

        `LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final SimpleSideDrawer mNav = new SimpleSideDrawer(this);
        mNav.setRightBehindContentView(R.layout.navigation);   
    
        View v = inflater.inflate(R.layout.navigation, null);
    
    
        Button buton = (Button) v.findViewById(R.id.buton);
    
        buton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("buton", "clicked");
    
            }
        });`
    

    Code seems fine but onclick does not called.

    Thanks in advance.

    opened by crescent7272 2
  • sometimes my Fragment be empt(i have check the input data is corrent)

    sometimes my Fragment be empt(i have check the input data is corrent)

    package com.ure.h22h.views;

    import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;

    import android.R.integer; import android.app.Activity; import android.content.ClipData.Item; import android.content.Intent; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.DrawerLayout; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView;

    import com.flurry.android.FlurryAgent; import com.google.android.gcm.GCMRegistrar; import com.navdrawer.SimpleSideDrawer; import com.ure.h22h.R; import com.ure.h22h.utils.Consts; import com.ure.h22h.utils.MainListAdapter; import com.ure.library.MyGenericListener; import com.ure.library.model.AzureHelper; import com.ure.library.model.Folder; import com.ure.library.model.GcmHelper; import com.ure.library.model.ViewHelper;

    import eu.inmite.android.lib.dialogs.ISimpleDialogListener; /**

    • @author ted
    • 主頁Activity頁面 */

    public class Main extends FragmentActivity implements ISimpleDialogListener,OnClickListener { private boolean _fansPage=false; private List<Map<String, Object>> _items; private SimpleSideDrawer _navigation; private MainListAdapter MainListAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); initNavigation(); initMenu(); //顯示首頁Fragment contrlFragment(0); countNewList();

    }
    
    //設定導覽
    private void initNavigation() {
        Log.d("ted", "initNavigation");
        _navigation = new SimpleSideDrawer(this);
        _navigation.setLeftBehindContentView(R.layout.navigation_content);
        findViewById(R.id.menu).setOnClickListener(this);
    }
    
    //預設選單設定
    private void initMenu() {
        Log.d("ted", "initNavigation");
        _items = new ArrayList<Map<String,Object>>();
        String[] menuName = getResources().getStringArray(R.array.menu_name);
        int[] image = {
                R.drawable.icon_star, R.drawable.icon_story, R.drawable.icon_shop,
                R.drawable.icon_activity, R.drawable.icon_food, R.drawable.icon_goods,
                R.drawable.icon_trip, R.drawable.icon_view, R.drawable.icon_bookmark
                , R.drawable.icon_facebook
    
        };
    
        //Menu圖片與文字
    
        for (int position = 0; position < menuName.length; position++) {
            Map<String, Object> item = new HashMap<String, Object>();
            item.put("Text", menuName[position]);
            item.put("Image", image[position]);
            item.put("New", "0");
            _items.add(item);
        }
    
        ListView _listView = (ListView) _navigation.findViewById(R.id.menu_list);
        MainListAdapter = new MainListAdapter(this,_items,image);
        _listView.setAdapter(MainListAdapter);
    
        _listView.setOnItemClickListener(new OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id){
                contrlFragment(position);
                _navigation.closeLeftSide();
    
            }
        });
    
    }
    
    
    //檢查是否有新東西並且顯示
    private void countNewList() {
        new  ViewHelper(this).getFoldersAsync(new MyGenericListener<ArrayList<Folder>>() {
            @Override
            public void onComplete(ArrayList<Folder> eventData) {
                try {
                    final int[] folderID = getResources().getIntArray(R.array.lib_setting_folderList);
                    for (int pos = 0; pos < eventData.size(); pos++){
                        for (int i = 0; i < folderID.length; i++) {
                            if(eventData.get(pos).getFolderID()==folderID[i]){
                                Map<String, Object> item = new HashMap<String, Object>();
                                item.put("Text", _items.get(i).get("Text"));
                                item.put("Image", _items.get(i).get("Image"));
                                item.put("New", eventData.get(pos).getContentCount_new().toString());
                                _items.set(i, item);
                            }
                        }
                    } 
                    MainListAdapter.notifyDataSetChanged();
                } catch (Exception e) {
                    // TODO: handle exception
                }
    
    
            }
    
            @Override
            public void onError(ArrayList<Folder> eventData) {
                // TODO Auto-generated method stub
    
            }
        });
    }
    
    
    //控制各分類fragment
    private void contrlFragment(int position) {
        Log.d("ted", String.valueOf(position));
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 
        Bundle data = new Bundle();
        switch (position) {
        case 0://首頁
            fragmentTransaction.replace(R.id.main_pager, new FHome()).commitAllowingStateLoss();
            _fansPage = false;
            break;
        case 9://粉絲團
            data.putString("Link", "https://m.facebook.com/tainan1616");
            data.putString("Title", "加入粉絲");
            FWebView FWebView =  new FWebView();
            FWebView.setArguments(data);
            fragmentTransaction.replace(R.id.main_pager,FWebView).commitAllowingStateLoss();
            _fansPage = true;
    
            break;
        default://預設
            Fragment CurrentFragment =null;
            CurrentFragment = new FMain();
            data.putInt("CurrentPage", position);
            CurrentFragment.setArguments(data);
            fragmentTransaction.replace(R.id.main_pager, CurrentFragment).commitAllowingStateLoss();
            _fansPage = false;
            break;
        }
    }
    
    
    // 註冊 Android 設備,以便日後可以收到 PUSH 訊息
    private void registerDevice(boolean allowPush)  {
        // 先儲存是否願意收到PUSH狀態,之後才能傳到 Server
        new ViewHelper(this).setPushState(allowPush);
    
        // 註冊 Android 設備,以便日後可以收到 PUSH 訊息
        GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
        String registationId = GCMRegistrar.getRegistrationId(this);
        if (registationId.equals(""))
            GCMRegistrar.register(this, Consts.GOOGLE_API_SENDERID);
        else {
            AzureHelper azureHelper = new AzureHelper(this);
            azureHelper.registerDevice(registationId, allowPush);
        }
    }
    
    private void registerDevice2(boolean allowPush) {
        // 先儲存是否願意收到PUSH狀態,之後才能傳到 Server
        new ViewHelper(this).setPushState(allowPush);
        // 註冊 Android 設備,以便日後可以收到 PUSH 訊息
        GcmHelper helper = new GcmHelper(this.getApplicationContext());
        helper.startRegister(allowPush);
    }
    
    @Override
    public void onBackPressed()
    {
        //網頁的BACK跟程式的BACK區分開來
        //          super.onBackPressed();
        if(_fansPage)
            FWebView.onBackPressed();
        else
            super.onBackPressed();
    }
    
    @Override
    protected void onStart()
    {
        super.onStart();
    
        //                  FlurryAgent.setLogLevel(Log.VERBOSE);
        FlurryAgent.onStartSession(this, Consts.FLURRY_KEY);
    }
    
    @Override
    protected void onStop()
    {
        super.onStop();     
        FlurryAgent.onEndSession(this);
    }
    
    
    
    /*
     * 接收附屬Fragment中的DialogFragment裡的requestCode
     * 不可寫在附屬的Fragment中會接收不到
     */
    @Override
    public void onPositiveButtonClicked(int requestCode) {
        switch (requestCode) {
        case 10:
            registerDevice2(true);
            break;
        case 11:
            final String PackgeParam = "com.ure.h22h";
            try{
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+PackgeParam)));
            }
            catch (android.content.ActivityNotFoundException anfe){
                // Open Google Play website
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+PackgeParam)));
            }
            break;
        case 12:
            //do nothing
            break;
        case 13:
            //do nothing
            break;
        }
    }
    
    
    @Override
    public void onNegativeButtonClicked(int requestCode) {
        switch (requestCode) {
        case 10:
            registerDevice2(false);
            break;
    
        }
    }
    
    
    
    @Override
    public void onClick(View v) {
        switch(v.getId()){
        case R.id.menu:
            _navigation.toggleLeftDrawer();
            break;
        }
    }
    

    }

    this my code

    first time usually is empty

    opened by ted66 1
  • Update SimpleSideDrawer.java

    Update SimpleSideDrawer.java

    setBehindContentView will throw a execption "java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first"

    Remove some useless code to let it work.

    opened by h3r3x3 0
  • want to open left side bar when I drag from left to right.

    want to open left side bar when I drag from left to right.

    Hi,

    I am trying to open left side bar when I will frag from left to right like google when side bar is closed.

    Can you please guide me how to do it.

    Now sidebar is closing and opening iwith dragging is possible when side bar is open.

    opened by digvijay-ryadav 2
  • Able to click left drawer layout button when drawer is not visible

    Able to click left drawer layout button when drawer is not visible

    Steps:

    1. Click on left menu button, left slider will open.
    2. Add toast event on Button click.

    device-2014-12-29-184301

    1. Close slider.
    2. Click below left menu button where Button of left slider is.
    3. Still it will display toast.

    device-2014-12-29-184326

    opened by sachinsandbhor 0
  • where is the simple-side-drawer2

    where is the simple-side-drawer2

    where is the simple-side-drawer2 ,you share the url can not be opened.

    thank you to share the library about the simple-side-drawer2

    [email protected]

    opened by flyingsirzw 0
Owner
null
An Android library that allows you to easily create applications with slide-in menus. You may use it in your Android apps provided that you cite this project and include the license in your app. Thanks!

SlidingMenu (Play Store Demo) SlidingMenu is an Open Source Android library that allows developers to easily create applications with sliding menus li

Jeremy Feinstein 11.1k Dec 21, 2022
Android - Blur Navigation Drawer like Etsy app.

Blur Navigation Drawer Library[DEPRECATED] Blur Navigation Drawer like Etsy app. Demo You can download a demo here. Updates Version 1.1 Add support fo

Vasilis Charalampakis 414 Nov 23, 2022
Space Navigation is a library allowing easily integrate fully customizable Google Spaces like navigation to your app.

Space-Navigation-View Introduction Space Navigation is a library allowing easily integrate fully customizable Google [Spaces][1] like navigation to yo

Arman 2k Dec 23, 2022
You can easily add awesome animated context menu to your app.

ContextMenu You can easily add awesome animated context menu to your app. Check this project on dribbble Check this project on Behance Usage: For a wo

Yalantis 3.8k Dec 28, 2022
Animations for Android L drawer, back, dismiss and check icons

Material Menu Morphing Android menu, back, dismiss and check buttons Have full control of the animation: Including in your project compile 'com.balysv

Balys Valentukevicius 2.5k Dec 30, 2022
swipe display drawer with flowing & bouncing effects.

FlowingDrawer swipe right to display drawer with flowing effects. Download Include the following dependency in your build.gradle file. Gradle: rep

mxn 2.6k Jan 3, 2023
Bottom Navigation widget component inspired by the Google Material Design Guidelines at https://www.google.com/design/spec/components/bottom-navigation.html

Material Bottom Navigation Library Lightweight Bottom Navigation library component inspired by the Google Material Design Guidelines at https://www.go

Alessandro Crugnola 1.4k Dec 18, 2022
A new way to implement navigation in your app 🏎

ExpandableBottomBar A new way to improve navigation in your app Its really easy integrate to your project take it, faster, faster Important: library w

Alexander Dadukin 692 Dec 29, 2022
A simple Floating Action Button that shows an anchored Navigation View

Floating Navigation View A simple Floating Action Button that shows an anchored Navigation View and was inspired by Menu Material Fixed created by Tom

André Mion 1.3k Dec 29, 2022
Unobtainables - Add unobtainable blocks to the creative menu

unobtainables Add unobtainable blocks to the creative menu

Richie Bendall 2 Jan 9, 2022
Spotify like android material bottom navigation bar library.

SuperBottomBar About Spotify like android material bottom navigation bar library. GIF Design Credits All design and inspiration credits belongs to Spo

Ertugrul 73 Dec 10, 2022
Navigation menu for Android (based off Google+ app)

RibbonMenu Navigation menu for Android (based on Google+ app). Usage Menus are created in xml as normal, adding text and an icon. In the layout you wa

David Scott 487 Nov 24, 2022
Implementation of "Side Navigation" or "Fly-in app menu" pattern for Android (based on Google+ app)

Android SideNavigation Library Implementation of "Side Navigation" or "Fly-in app menu" pattern for Android (based on Google+ app). Description The Go

Evgeny Shishkin 319 Nov 25, 2022
A customizable and easy to use BottomBar navigation view with sleek animations, with support for ViewPager, ViewPager2, NavController, and badges.

AnimatedBottomBar A customizable and easy to use bottom bar view with sleek animations. Examples Playground app Download the playground app from Googl

Joery 1.2k Dec 30, 2022
🚀 A very customizable library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet.

SlidingUpMenu A library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet. Gradle Dependency

Rasheed Sulayman 26 Jul 17, 2022
A menu which can ... BOOM! - Android

BoomMenu 2.0.0 Comes Finally Approximately 8 months ago, I got an inspiration to creating something that can boom and show menu, which I named it Boom

Nightonke 5.8k Dec 27, 2022
An android custom view which looks like the menu in Path 2.0 (for iOS).

ArcMenu & RayMenu ArcMenu An android custom view which looks like the menu in Path 2.0 (for iOS). RayMenu About The user experience in Path 2.0 (for i

daCapricorn 1.3k Nov 29, 2022
BottomSheet-Android - A simple customizable BottomSheet Library for Android Kotlin

BottomSheet-Android A simple customizable BottomSheet Library for Android Kotlin

Munachimso Ugorji 0 Jan 3, 2022