jfeinstein10 / SlidingMenu

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!
Apache License 2.0
11.08k stars 5.05k forks source link

Switch Fragment when click on Sliding Menu items #411

Open pratikbutani opened 11 years ago

pratikbutani commented 11 years ago

How to switch Fragment when click on Sliding menu items, please help

chitgoks commented 11 years ago

hi, you need to learn more about fragments. check the android tutorial on fragmenttransaction

alicanbatur commented 11 years ago

Hi, here is your code.

This is in the fragment of left menu, on click item. (I use listfragment)

                    getActivity().getSupportFragmentManager().beginTransaction()
                .replace(R.id.content_frame, new YourNewFragment())
                .commit(); // R.id.content_frame  is your main_activity.xml's main part. Give id = content_frame to root. And YourNewFragment is your new fragment class. If you want to know how, create a class, name it YourNewFragment.Extend it from Fragment. Then in its onCreateView method, inflate fragments own xml layout.
        ((BaseActivity) getActivity()).toggle();//Closes sliding content