title: Parsing android resources from xml
body: <p>I am facing some problems with parsing a XML-file for my Android App.</p>
  
  <p>I need some layout ids and color ids from my XML file. I have no problems in reading string values but I dont know how to convert the XML layout reference to a layout id? Thanks for your help!!</p>
  
  <p>My XML file looks like that:</p>
  
  <pre><code>&lt;program
      name="ProgramName"
      color="@color/white"
      prefLayoutId="@layout/pref" /&gt;
  </code></pre>
  
  <p>My parsing code works like that. The parsing of color/layout does not work:</p>
  
  <pre><code>XmlPullParser xmlParser = getResources().getXml(R.xml.programlist);
  
  int event = xmlParser.getEventType();
  while (event != XmlPullParser.END_DOCUMENT) {
      String name = xmlParser.getName();
  
      switch (event) {
          case XmlPullParser.START_TAG: {
              break;
          }
          case XmlPullParser.END_TAG: {
              if(name.equals("program")) {
                  ProgramInfo pi = new ProgramInfo();
  
                  pi.name = xmlParser.getAttributeValue(null, "name");
  
                  // HERE I need something like COLOR.Black;
                  pi.color = Integer.valueOf(xmlParser.getAttributeValue(null, "color"));
  
                  // HERE I need something like R.layout.pref
                  pi.pref = Integer.valueOf(xmlParser.getAttributeValue(null, "prefLayoutId"));
  
                  result.add(pi);
           }
           break;
       }
  }
  
  event = xmlParser.next();
  </code></pre>