title: How to change the Background color of selected item in the Navigation Drawer
body: <p>I was working on Nav drawer on my app.
  I have made the background of my nav drawer #000000(Black). Whenever I select any item the textcolor of text changes from #E44F50(Carrot Red) to black but I cant change the background color of the selected item.
  All I want is to change the background color of selected Item from black to carrot red.</p>
  
  <p>Here is the github link to my app-</p>
  
  <p><a href="https://github.com/manmeet-22/NewsSnips-app.git" rel="noreferrer">https://github.com/manmeet-22/NewsSnips-app.git</a></p>
  
  <pre><code>&lt;android.support.design.widget.NavigationView
          android:id="@+id/navigation_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:background="@color/colorPrimary"
          app:headerLayout="@layout/header"
          app:itemIconTint="@drawable/drawer_item" //changing text color 
          app:itemTextAppearance="@style/TextAppearance20"
          app:itemTextColor="@color/drawer_item"
          app:itemBackground="@drawable/drawer_selected_item" //trying to change backgroundcolor the same way
          app:menu="@menu/drawer"
          tools:context="com.androidexample.newssnips.app.NavigationDrawerFragment"/&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>In this I tried changing the background color like I did for the text but my app crashes.</p>
  
  <p>here is my drawer_selected_item.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item android:color="@color/colorAccent" android:state_selected="true"/&gt;
      &lt;item android:color="@android:color/transparent"/&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>here is my drawer_item.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
          &lt;item android:color="@color/colorPrimary" android:state_checked="true" /&gt;
          &lt;item android:color="@color/colorAccent" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>Here is my MainActivity.java:</p>
  
  <pre><code>navigationView = (NavigationView) findViewById(R.id.navigation_view);
          navigationView.setItemIconTintList(null);
          Menu menu = navigationView.getMenu();
  
          //For chnaging the textColor and textSize of group's Name ie. Category
          MenuItem categoryName= menu.findItem(R.id.categoryGroup);
          SpannableString s = new SpannableString(categoryName.getTitle());
          s.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance25), 0, s.length(), 0);
  
          //For changing the Text of action bar as the selected category
          categoryName.setTitle(s);
  
          //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 open the Appopriate news accordingly
                  switch (menuItem.getItemId()) {
  
                      case R.id.itemWorld:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=world";
                          setTitle("World News");
  
                          basicDefaults();
                          return true;
                      case R.id.itemFootball:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=football";
                          setTitle("Football News");
                          basicDefaults();
                          return true;
                      case R.id.itemFashion:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=fashion";
                          setTitle("Fashion News");
                          basicDefaults();
                          return true;
                      case R.id.itemSports:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=sport";
                          setTitle("Sports News");
                          basicDefaults();
                          return true;
                      case R.id.itemBusiness:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=business";
                          setTitle("Business News");
                          basicDefaults();
                          return true;
                      case R.id.itemTechnology:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=technology";
                          setTitle("Technology News");
                          basicDefaults();
                          return true;
                      case R.id.itemOpinion:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=commentisfree";
                          setTitle("Opinions");
                          basicDefaults();
                          return true;
                      case R.id.itemCulture:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=culture";
                          setTitle("Culture News");
                          basicDefaults();
                          return true;
                      case R.id.itemTravel:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=travel";
                          setTitle("Travel News");
                          basicDefaults();
                          return true;
                      case R.id.itemLifestyle:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=lifeandstyle";
                          setTitle("LifeStyle News");
                          basicDefaults();
                          return true;
                      case R.id.itemEnvironment:
                          GAURDIAN_REQUEST_URL = "http://content.guardianapis.com/search?api-key=f51fa87d-8a55-4fc1-b552-8fa6eb98dee4&amp;section=environment";
                          setTitle("Environment News");
                          basicDefaults();
                          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);
  
              }
          };
  
          //calling sync state is necessay or else your hamburger icon wont show up
          actionBarDrawerToggle.syncState();
      }
  </code></pre>
  
  <p>PS.- I have tried implementing other methods too like</p>
  
  <p>adding this in apptheme in styles.xml file.</p>
  
  <pre><code>&lt;item name="android:activatedBackgroundIndicator"&gt;@drawable/drawer_selected_item&lt;/item&gt;
  </code></pre>
  
  <p>But still I cant find my solution.<br>
  Please help it is the last thing that is left in my project.</p>