1

I saw a couple libraries that can do this, but i would like to avoid them if possible. I managed to do left to right, but i couldn't find out how to do on both directions. so here is my code:

    final SlidingPaneLayout slidingPaneLayout = SlidingPaneLayout.class.cast(root.findViewById(R.id.slidingpanelayout));
    slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {

        @Override
        public void onPanelSlide(View view, float v) {
        }

        @Override
        public void onPanelOpened(View view) {

            switch (view.getId()) {
                case R.id.fragment_secondpane:
                    getSupportFragmentManager().findFragmentById(R.id.fragment_firstpane).setHasOptionsMenu(true);
                    getSupportFragmentManager().findFragmentById(R.id.fragment_secondpane).setHasOptionsMenu(false);
                    break;
                default:
                    break;
            }
        }

        @Override
        public void onPanelClosed(View view) {

            switch (view.getId()) {
                case R.id.fragment_secondpane:
                    getSupportFragmentManager().findFragmentById(R.id.fragment_firstpane).setHasOptionsMenu(false);
                    getSupportFragmentManager().findFragmentById(R.id.fragment_secondpane).setHasOptionsMenu(true);
                    break;
                default:
                    break;
            }
        }
    });

is there a way to make sliding panels on both left to right and right to left directions so that i will have 3 fragments, without any libraries?

Filip Luchianenco
  • 6,912
  • 9
  • 41
  • 63
  • 1
    Take a look at https://github.com/Ali-Rezaei/SlidingDrawer which makes it possible to slide from any side by few lines of code. – Ali Jun 13 '15 at 19:39

1 Answers1

4

Your solution lies in ViewPager. Here are a couple of links for tutorial.

Detailed Tutorial with source code and xml files

Vogella Tutorial for ViewPage


UPDATE

What you are asking about is Navigation Drawer. You can find tons of tutorial on internet. Here are some good ones.

Android Official Tutorial

Detailed tutorial for Beginers

Hope this helps

Umer Farooq
  • 7,356
  • 7
  • 42
  • 67
  • it does a bit different as i can see: http://www.edumobile.org/android/wp-content/uploads/2012/08/pathfinderexample4.png http://www.edumobile.org/android/wp-content/uploads/2012/08/pathfinderexample5.png mine has to look like this: https://www.dropbox.com/s/cxkkpbwim646bly/3.jpg https://www.dropbox.com/s/dra1sc7jx0nc5zo/2.jpg will i be able to configure it like this? – Filip Luchianenco Sep 06 '13 at 10:56
  • Man this is not called sliding panel. You are confused. It is called Navigation drawer. – Umer Farooq Sep 06 '13 at 11:05
  • here is how it looks now with the code i posted in the question: https://www.dropbox.com/s/lzrn1yjt7243fgf/2013-09-06%2014.07.53.png can't i simply add another one in opposite direction? – Filip Luchianenco Sep 06 '13 at 11:09
  • 1
    yes you can do that but your code might not be optimized for performance or it may havecompatiblity issues with different screen sizes. So it always better to use official libraries (if they exist for required scenario), if they don't exist, only then you should write your own code. – Umer Farooq Sep 06 '13 at 11:24
  • thank you. i will use libraries then, i just wanted less dependencies. add this in you answer so that it will help others. – Filip Luchianenco Sep 06 '13 at 11:27