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

前端 未结 1 708
[愿得一人]
[愿得一人] 2020-12-18 17:29

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 fo

1条回答
  •  时光说笑
    2020-12-18 17:41

    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

    0 讨论(0)
提交回复
热议问题