title: TypeArray in Android - How to store custom objects in xml and retrieve them?
body: <p>I have a class like</p>
  <pre><code>public class CountryVO {
      private String countryCode;
      private String countryName;
      private Drawable countryFlag;
      
      public String getCountryCode() {
          return countryCode;
      }
      public void setCountryCode(String countryCode) {
          this.countryCode = countryCode;
      }
      public String getCountryName() {
          return countryName;
      }
      public void setCountryName(String countryName) {
          this.countryName = countryName;
      }
      public Drawable getCountryFlag() {
          return countryFlag;
      }
      public void setCountryFlag(Drawable countryFlag) {
          this.countryFlag = countryFlag;
      }
  }
  </code></pre>
  <p>and want to store objects of this class in an TypeArray xml of android like</p>
  <pre><code>&lt;resources&gt;
      &lt;array name=&quot;custom_arr&quot;&gt;
          &lt;item&gt;
              &lt;countryName&gt;Albania&lt;/countryName&gt;
              &lt;countryCode&gt;al&lt;/countryCode&gt;
              &lt;countryFlag&gt;@drawable/al&lt;/countryFlag&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;countryName&gt;Algeria&lt;/countryName&gt;
              &lt;countryCode&gt;dz&lt;/countryCode&gt;
              &lt;countryFlag&gt;@drawable/dz&lt;/countryFlag&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;countryName&gt;American Samoa&lt;/countryName&gt;
              &lt;countryCode&gt;as&lt;/countryCode&gt;
              &lt;countryFlag&gt;@drawable/as&lt;/countryFlag&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;countryName&gt;India&lt;/countryName&gt;
              &lt;countryCode&gt;in&lt;/countryCode&gt;
              &lt;countryFlag&gt;@drawable/in&lt;/countryFlag&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;countryName&gt;South Africa&lt;/countryName&gt;
              &lt;countryCode&gt;sa&lt;/countryCode&gt;
              &lt;countryFlag&gt;@drawable/sa&lt;/countryFlag&gt;
          &lt;/item&gt;
      &lt;/array&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>how i want to access this array in my Activty class like</p>
  <pre><code>TypedArray customArr = getResources().obtainTypedArray(R.array.country_arr);
      CountryVO vo = new CountryVO();
      vo.setCountryName(**value from array come here for first element's countryName attribute**);
      vo.setCountryCode(**value from array come here for first element's countryCode attribute**);
      vo.setCountryFlag(**value from array come here for first element's countryFlag attribute**);
  </code></pre>
  <p>But i don't to how to achieve this.
  I tried customArr.getString(0); but it gives me everything as string like
  Albania al @drawable/al</p>
  <p>Please help me to solve this problem.</p>
  <p>Thanks a lot in advance,</p>
  <p>With best regards,
  Ishan</p>