no more allow open Drawer layout from right side in navigation drawer
Asked Answered
H

1

0

I want to open drawer from right side, but when swite it works but when i click on toggle button in action bar it force close and give error that "No drawer view found with gravity LEFT"

please help...

I add layout like

 <ListView
            android:layout_gravity="right|end"
            android:id="@+id/left_drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:divider="#ccc"
            android:dividerHeight="1dp"

   />

Error:

 java.lang.IllegalArgumentException: No drawer view found with gravity LEFT
        at android.support.v4.widget.DrawerLayout.openDrawer(DrawerLayout.java:1319)
        at android.support.v7.app.ActionBarDrawerToggle.toggle(ActionBarDrawerToggle.java:290)
        at android.support.v7.app.ActionBarDrawerToggle.access$100(ActionBarDrawerToggle.java:64)
        at android.support.v7.app.ActionBarDrawerToggle$1.onClick(ActionBarDrawerToggle.java:200)
        at android.view.View.performClick(View.java:4084)
        at android.view.View$PerformClick.run(View.java:16966)
        at android.os.Handler.handleCallback(Handler.java:615)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
Hospitaler answered 8/6, 2015 at 10:19 Comment(0)
T
6

i have same issue, and i fix it bellow:

toolbar = (Toolbar) findViewById(R.id.tool_bar);

Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout);

mDrawerToggle = new ActionBarDrawerToggle(this,Drawer,toolbar,R.string.openDrawer,R.string.closeDrawer){

    @Override
    public void onDrawerOpened(View drawerView) {
        super.onDrawerOpened(drawerView);
    }
    @Override
    public void onDrawerClosed(View drawerView) {
        super.onDrawerClosed(drawerView);
    }
}; // Drawer Toggle Object Made
Drawer.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();               

toolbar.setNavigationOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        if (Drawer.isDrawerOpen(Gravity.RIGHT)) {
            Drawer.closeDrawer(Gravity.RIGHT);
        } else {
            Drawer.openDrawer(Gravity.RIGHT);
        }
    }
});

yes, it's work, i'm fix this bug in 5hour :( but i'm very happy when resolve it. ^^ thanks & good luck

Tweak answered 9/6, 2015 at 17:20 Comment(1)
Hi @Tweak can you make the drawer icon on the right in toolbar too ?Photobathic

© 2022 - 2024 — McMap. All rights reserved.