0

I have a program and I want to implement a sliding menu.

First I tryed Navigation Drawer Navigation Drawer which is what I basically want because:

1) It doesn't push the screen, it cover it 2) When I click on button up left it opens the menu 3) When I try to click on the screen to another

But on the other hand:

I don't want to have a button up left, I want the user to click a button from the screen and every time a different sliding menu comes up.

I tryed also jfeinstein10 Sliding Menu , but it doesn't cover the screen it only push it away and they have told me that it's not possible to change that. But on other hand, it is easy and better on some ways.

So any ideas how to 1) not have up left icon/button and 2) how to handle the navigation drawer with a button?

Edit:

I want to have a sliding menu that covers the screen not to push the screen

pap
  • 283
  • 1
  • 7
  • 18

3 Answers3

0

There is slider.jar android library for this which give better result for navigation drawer

slide_me = new SimpleSideDrawer(this);

slide_me.setRightBehindContentView(R.layout.setting_activity);

and on button click use the following code

 slide_me.toggleRightDrawer(); // for open drawer from right side
 slide_me.toggleLeftDrawer(); // for open drawer from left side 
user8938
  • 559
  • 1
  • 4
  • 12
  • You mean that [Simple Drawer](https://github.com/adamrocker/simple-side-drawer)? Because the way I see it, it doesn't cover the screen it is pushing the screen and after that I do not want have a button up left and instead of I want to have a button on my main screen to handle the navigation drawer – pap Mar 13 '14 at 14:04
0

Why don't you set a ViewGroup in the Navigation Drawer such as LinearLayout and addView with the correct view, created by inflating it. And removeAllViews() afterwards

on button click:

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View myView = inflater.inflate(R.layout.layout_i_want_in_my_drawer, null, false);
navigationViewGroup.addView(myView);
drawerToggle.openDrawer(Gravity.LEFT);

in actionbardrawertoggle's ondrawerclose():

navigationViewGroup.removeAllViews();

This code is not tested

first of all, follow the official tutorial: https://developer.android.com/training/implementing-navigation/nav-drawer.html

dumazy
  • 13,857
  • 12
  • 66
  • 113
0

Thanks dumazy I have found half of my answer and thanks to that Add button to activity with navigation drawer. The trick were in Gravity and to create a method in order to call it in my onClick Listener for the specific button.

Then the other half was just code deleting in the lines that the imagebutton up left was mentioned in order to open the Navigation Drawer.

Button onClick Listener:

    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            open();         }
    });

Method:

        public void open(){
    mDrawerLayout.openDrawer(Gravity.LEFT);
   }
Community
  • 1
  • 1
pap
  • 283
  • 1
  • 7
  • 18