title: Android : How to replace navigation-drawer icons with font-awesome icons(icons available)
body: <p>I am working on an Android project in which I have a navigation drawer which shows a list of <code>GroupSection</code> objects. All the GroupSection objects contain a section icon. The drawer icons are determined by a TypedArray and some android specific syntax to get the resource. I want to replace that with a font-awesome icon. Each groupSection object has a getter <code>groupSection.getSectionIcon();</code> which returns me the String of icon. I have added the icons in String.xml and have the <code>fontawesome-webfont.ttf</code> in assets directory.</p>
  
  <p>I just cannot figure out how to replace the typed array with font-awesome icon. I tried <code>findViewByID(R.id.awesome_icon).getId()</code>, and some other possibilites. Thank you.</p>
  
  <p>COde :</p>
  
  <pre><code>  public void set(List&lt;RestSection&gt; restSectionList, TypedArray navMenuIcons, Long groupId,
                      int canvasid, int sectionId) {
  // Below are default icons
    navMenuIcons = getResources()
                  .obtainTypedArray(R.array.nav_drawer_icons);
    for (RestSection restSection : restSectionList) {
  
  // As you can see I am accessing the icons with there resource id. 
              navDrawerItems.add(new DrawerModel(restSection.getMsectionname(),
                      navMenuIcons.getResourceId(0, -1), restSection.getMsectionid()));
          }
  </code></pre>
  
  <p>Sample of string.xml :</p>
  
  <pre><code> &lt;string name="pinterest"&gt;&amp;#xf0d2;&lt;/string&gt;
      &lt;string name="pinterest_square"&gt;&amp;#xf0d3;&lt;/string&gt;
      &lt;string name="google_plus_square"&gt;&amp;#xf0d4;&lt;/string&gt;
      &lt;string name="google_plus"&gt;&amp;#xf0d5;&lt;/string&gt;
      &lt;string name="money"&gt;&amp;#xf0d6;&lt;/string&gt;
      &lt;string name="caret_down"&gt;&amp;#xf0d7;&lt;/string&gt;
      &lt;string name="caret_up"&gt;&amp;#xf0d8;&lt;/string&gt;
      &lt;string name="caret_left"&gt;&amp;#xf0d9;&lt;/string&gt;
      &lt;string name="caret_right"&gt;&amp;#xf0da;&lt;/string&gt;
      &lt;string name="columns"&gt;&amp;#xf0db;&lt;/string&gt;
  </code></pre>
  
  <p>As in the for-loop I can directly get the icon String with getter, but setting it is where the issue lies. Any help would be nice. Thank you. :-)</p>
  
  <p><em>Update</em></p>
  
  <p>I tried the below code where I would manually set, but I get error for that as well :</p>
  
  <pre><code>Unable to find resource: 2131165836
   android.content.res.Resources$NotFoundException: File  from drawable resource ID #0x7f07028c
    at android.content.res.Resources.loadDrawableForCookie(Resources.java:2640)
  at android.content.res.Resources.loadDrawable(Resources.java:2540)
  at android.content.res.Resources.getDrawable(Resources.java:806)
  at android.content.Context.getDrawable(Context.java:458)
  at android.widget.ImageView.resolveUri(ImageView.java:811)
  at android.widget.ImageView.setImageResource(ImageView.java:418)
  </code></pre>
  
  <p>Code :</p>
  
  <pre><code>for (RestSection restSection : restSectionList) {
              if (restSection.getSectionIcon() != null) {
                  DrawerModel drawerModel = new DrawerModel();
                  drawerModel.setTitle(restSection.getMsectionname());
                  drawerModel.setId(restSection.getMsectionid());
                  drawerModel.setIcon(R.string.try_icon);
  
                  navDrawerItems.add(drawerModel);
              } else {
                  navDrawerItems.add(new DrawerModel(restSection.getMsectionname(),
                          navMenuIcons.getResourceId(0, -1), restSection.getMsectionid()));
              }
          }
  </code></pre>