title: Add Icons to Android Navigation Drawer?
body: <p>I have scoured the web for an answer to this question but cannot seem to find one, even in the official Android documentation.</p>
  
  <p>I am in the process of creating an app that implements Android's new Navigation Drawer layout. Documentation of this layout can be found <a href="https://developer.android.com/training/implementing-navigation/nav-drawer.html" rel="noreferrer">here</a> and <a href="https://developer.android.com/design/patterns/navigation-drawer.html" rel="noreferrer">here</a>.</p>
  
  <p>In the design documentation as well as in a number of popular apps such as Facebook and Google Currents, the drawer items have icons in front of them.</p>
  
  <p>The design documentation itself mentions them, under "Content of the Navigation Drawer"</p>
  
  <blockquote>
    <p>Navigation targets can have optional leading icons as well as trailing counters. Use the counters to inform users about a changed state of data in the corresponding view.</p>
  </blockquote>
  
  <p>Unfortunately, the Developer documentation makes no mention of how to implement icons in this setup. It describes how to implement the list of items as so: </p>
  
  <pre><code>public class MainActivity extends Activity {
  private String[] mPlanetTitles;
  private ListView mDrawerList;
  ...
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      mPlanetTitles = getResources().getStringArray(R.array.planets_array);
      mDrawerList = (ListView) findViewById(R.id.left_drawer);
  
      // Set the adapter for the list view
      mDrawerList.setAdapter(new ArrayAdapter&lt;String&gt;(this,
              R.layout.drawer_list_item, mPlanetTitles));
      // Set the list's click listener
      mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
  
      ...
  }
  }
  </code></pre>
  
  <p>Because their implementation uses getStringArray(), there is no way I can think of to modify the row item's xml to include an icon. </p>
  
  <p>This is baffling, because many apps seem to implement icons before each text item just fine, and the Design documentation even makes reference to adding icons. I feel that there must be some simple API call to accomplish adding these icons, and yet the only implementation I have found so far seems ridiculously complicated. </p>
  
  <p>Does anyone know how to add icons to the Navigation Drawer items? Is there a way to do this with a simple API call, or have all these companies (Facebook, Google, etc) had to find ways to hack around the problem?</p>
  
  <p>Thanks everyone.</p>