Why is isDrawerVisible always showing as false

Carlos

So, I have this

btn_menu.setOnClickListener(new View.OnClickListener() {
@Override

        public void onClick(View v) {if(mDrawerLayout.isDrawerVisible(R.id.drawer_layout) == false) {
                mDrawerLayout.openDrawer(mDrawerList);
                Log.d("False", "" + mDrawerLayout.isDrawerOpen(R.id.drawer_layout));
            } else {
                mDrawerLayout.closeDrawer(mDrawerLayout);
                Log.d("True", "" + mDrawerLayout.isDrawerOpen(R.id.drawer_layout));
            }
        }
    });

On the "btn_menu" click I will open and close the drawer, thing is that no matter what I do the method "isDrawerOpen" will ALWAYS return false. I don't know what else to do.

Here is the layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->

<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>

Edit: blipinsk answer was right. But I had to change the if test too.

if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                    mDrawerLayout.closeDrawer(Gravity.LEFT);
                } else {
                    mDrawerLayout.openDrawer(Gravity.LEFT);
                }
Bartek Lipinski

When you call isDrawerOpen you need to specify which drawer (there can be two - one on the right and one on the left) you are trying to check.

So in your case it should be:

mDrawerLayout.isDrawerOpen(Gravity.LEFT)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why is isDrawerVisible always showing as false

From Dev

Why the if condition is always false?

From Dev

If always false, why?

From Dev

why it is always showing output as 1?

From Dev

Why is typeid always returning false?

From Dev

Why is my condition always false?

From Dev

Why is my if statement always false?

From Dev

Why the Auth::attempt method always returns false?

From Dev

WHY is comparison of unsigned expression < 0 always false

From Dev

Why is IsNewRow property always returning false?

From Dev

Why does the Synchronized method always return false?

From Dev

Function always returns False. Why?

From Dev

Why parseInt(key) === NaN always evaluates to false

From Dev

Why does sonar think this expression is always false

From Dev

Why Laravel Auth::check always return false?

From Dev

Why WinAPI FormatMessage fails, always returns false

From Dev

Why string comparision results always false

From Dev

Why is the first condition of "else if" statement always false?

From Dev

Why is my condition showing false results?

From Dev

Fragment Will Not Switch Back View and Boolean Variable is Showing as Always False

From Dev

Why is my alert always showing the wrong information? (addition)

From Dev

Why Is My Jquery Slide div always showing at the start

From Dev

Why Is My Jquery Slide div always showing at the start

From Dev

Why is bash 'not always' showing the 'Terminated' message after killing a process?

From Dev

why is facebook login fragment always showing invalid key hash in android?

From Dev

Why does my ACF custom field return always false or array?

From Dev

JQuery hasClass - why does it always return false in this case?

From Dev

Explaining why false and modulus always equate true in Javascript

From Java

Why is my ClaimsIdentity IsAuthenticated always false (for web api Authorize filter)?

Related Related

  1. 1

    Why is isDrawerVisible always showing as false

  2. 2

    Why the if condition is always false?

  3. 3

    If always false, why?

  4. 4

    why it is always showing output as 1?

  5. 5

    Why is typeid always returning false?

  6. 6

    Why is my condition always false?

  7. 7

    Why is my if statement always false?

  8. 8

    Why the Auth::attempt method always returns false?

  9. 9

    WHY is comparison of unsigned expression < 0 always false

  10. 10

    Why is IsNewRow property always returning false?

  11. 11

    Why does the Synchronized method always return false?

  12. 12

    Function always returns False. Why?

  13. 13

    Why parseInt(key) === NaN always evaluates to false

  14. 14

    Why does sonar think this expression is always false

  15. 15

    Why Laravel Auth::check always return false?

  16. 16

    Why WinAPI FormatMessage fails, always returns false

  17. 17

    Why string comparision results always false

  18. 18

    Why is the first condition of "else if" statement always false?

  19. 19

    Why is my condition showing false results?

  20. 20

    Fragment Will Not Switch Back View and Boolean Variable is Showing as Always False

  21. 21

    Why is my alert always showing the wrong information? (addition)

  22. 22

    Why Is My Jquery Slide div always showing at the start

  23. 23

    Why Is My Jquery Slide div always showing at the start

  24. 24

    Why is bash 'not always' showing the 'Terminated' message after killing a process?

  25. 25

    why is facebook login fragment always showing invalid key hash in android?

  26. 26

    Why does my ACF custom field return always false or array?

  27. 27

    JQuery hasClass - why does it always return false in this case?

  28. 28

    Explaining why false and modulus always equate true in Javascript

  29. 29

    Why is my ClaimsIdentity IsAuthenticated always false (for web api Authorize filter)?

HotTag

Archive