title: Android - No drawer View found with gravity LEFT
body: <p>I'm trying to make a <code>DrawerLayout</code> slides from right to left.</p>
  
  <p>I've followed <a href="http://www.android4devs.com/2015/06/navigation-view-material-design-support.html" rel="nofollow">this tutorial</a> and found it very satisfying and clear for a <code>DrawerLayout</code> which slides from left to right.</p>
  
  <p>When I change the <code>gravity</code> of <code>android.support.design.widget.NavigationView</code> to <code>right</code>, it slides from right to left, but, the burger button isn't working properly anymore, it shows <code>No drawer view found with gravity LEFT</code> when I tried touching it.</p>
  
  <p>Here's the modified toggle function</p>
  
  <pre><code>// Initializing Drawer Layout and ActionBarToggle
          drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
          ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.openDrawer, R.string.closeDrawer){
  
              @Override
              public void onDrawerClosed(View drawerView) {
                  // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank
                  super.onDrawerClosed(drawerView);
              }
  
              @Override
              public void onDrawerOpened(View drawerView) {
                  // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank
  
                  super.onDrawerOpened(drawerView);
              }
  //Added the lines below, tried solutions online but fail..
              @Override
              public boolean onOptionsItemSelected(MenuItem item) {
                  if (item != null &amp;&amp; item.getItemId() == android.R.id.home) {
                      if (drawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                          drawerLayout.closeDrawer(Gravity.RIGHT);
                      } else {
                          drawerLayout.openDrawer(Gravity.RIGHT);
                      }
                  }
                  return false;
              }
  
          };
  </code></pre>
  
  <p>So.. How to make the burger button work again?</p>
  
  <p>UPDATE</p>
  
  <p>Here's the XML file of the main layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/drawer"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context=".Activities.NewsfeedActivity"&gt;
  
      &lt;LinearLayout
          android:id="@+id/activity_newsfeed_wrapper"
          android:layout_height="match_parent"
          android:layout_width="match_parent"
          android:orientation="vertical" &gt;
  
          &lt;android.support.v7.widget.Toolbar
              xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:id="@+id/activity_newsfeed_toolbar"
              android:layout_width="match_parent"
              android:layout_height="@dimen/abc_action_bar_default_height_material"
              app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/&gt;
  
          &lt;FrameLayout
              android:id="@+id/activity_newsfeed_frame"
              android:layout_width="match_parent"
              android:layout_height="match_parent"&gt;
  
          &lt;/FrameLayout&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/activity_newsfeed_navigationView"
          android:layout_height="match_parent"
          android:layout_width="wrap_content"
          android:layout_gravity="right"
          app:headerLayout="@layout/drawer_header"
          app:menu="@menu/drawer" /&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>Here's my main class</p>
  
  <pre><code>public class NewsfeedActivity extends AppCompatActivity {
  
      //Defining Variables
      private Toolbar toolbar;
      private NavigationView navigationView;
      private DrawerLayout drawerLayout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_newsfeed);
  
          // Initializing Toolbar and setting it as the actionbar
          toolbar = (Toolbar) findViewById(R.id.activity_newsfeed_toolbar);
          setSupportActionBar(toolbar);
  
          //Initializing NavigationView
          navigationView = (NavigationView) findViewById(R.id.activity_newsfeed_navigationView);
  
          //Setting Navigation View Item Selected Listener to handle the item click of the navigation menu
          navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
  
              // This method will trigger on item Click of navigation menu
              @Override
              public boolean onNavigationItemSelected(MenuItem menuItem) {
  
  
                  //Checking if the item is in checked state or not, if not make it in checked state
                  if(menuItem.isChecked()) menuItem.setChecked(false);
                  else menuItem.setChecked(true);
  
                  //Closing drawer on item click
                  drawerLayout.closeDrawers();
  
                  //Check to see which item was being clicked and perform appropriate action
                  switch (menuItem.getItemId()){
  
  
                      //Replacing the main content with ContentFragment Which is our Inbox View;
                      case R.id.a:
                          Toast.makeText(getApplicationContext(), "Inbox Selected", Toast.LENGTH_SHORT).show();
                          ContentFragment fragment = new ContentFragment();
                          android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
                          fragmentTransaction.replace(R.id.activity_newsfeed_frame,fragment);
                          fragmentTransaction.commit();
                          return true;
  
                      // For rest of the options we just show a toast on click
  
                      case R.id.b:
                          Toast.makeText(getApplicationContext(),"b Selected",Toast.LENGTH_SHORT).show();
                          return true;
                      case R.id.c:
                          Toast.makeText(getApplicationContext(),"c Selected",Toast.LENGTH_SHORT).show();
                          return true;
                      case R.id.d:
                          Toast.makeText(getApplicationContext(),"d Selected",Toast.LENGTH_SHORT).show();
                          return true;
                      case R.id.e:
                          Toast.makeText(getApplicationContext(),"e Selected",Toast.LENGTH_SHORT).show();
                          return true;
                      case R.id.f:
                          Toast.makeText(getApplicationContext(),"f Selected",Toast.LENGTH_SHORT).show();
                          return true;
                      case R.id.g:
                          Toast.makeText(getApplicationContext(),"g Selected",Toast.LENGTH_SHORT).show();
                          return true;
                      case R.id.h:
                          Toast.makeText(getApplicationContext(),"h Selected",Toast.LENGTH_SHORT).show();
                          return true;
                      default:
                          Toast.makeText(getApplicationContext(),"Somethings Wrong",Toast.LENGTH_SHORT).show();
                          return true;
  
                  }
              }
          });
  
          // Initializing Drawer Layout and ActionBarToggle
          drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
          ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.openDrawer, R.string.closeDrawer){
  
              @Override
              public void onDrawerClosed(View drawerView) {
                  // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank
                  super.onDrawerClosed(drawerView);
              }
  
              @Override
              public void onDrawerOpened(View drawerView) {
                  // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank
  
                  super.onDrawerOpened(drawerView);
              }
  
          };
  
          //Setting the actionbarToggle to drawer layout
          drawerLayout.setDrawerListener(actionBarDrawerToggle);
  
          //calling sync state is necessay or else your hamburger icon wont show up
          actionBarDrawerToggle.syncState();
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.drawer, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          switch (item.getItemId()) {
              case android.R.id.home:
                  if (drawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                      drawerLayout.closeDrawer(Gravity.RIGHT);
                  } else {
                      drawerLayout.openDrawer(Gravity.RIGHT);
                  }
                  return true;
              case R.id.action_settings:
                  return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
  }
  </code></pre>
  
  <p>Update 02/02/2016</p>
  
  <p>Tried changing drawer view to <code>RIGHT</code>.. But it's a bad idea because nothing changes. Tried moving <code>NavigationView</code> into the <code>LinearLayout</code>, it's even worse because there'll be no sliding menu..</p>
  
  <p>Tried changing things in <code>onOptionsItemSelected</code></p>
  
  <pre><code>case android.R.id.home:
                  if (drawerLayout.isDrawerOpen(GravityCompat.END)) {
                      drawerLayout.closeDrawer(GravityCompat.END);
                  } else {
                      drawerLayout.openDrawer(GravityCompat.END);
                  }
  </code></pre>
  
  <p>Changed <code>Gravity.RIGHT</code> to <code>GravityCompat.END</code>, "NOPE", the code says..</p>