title: Using Reflection with Android
body: <p>I faced an interesting problem today. I have 4 strings which I need to show on app on random basis. So I simply added the strings to my string.xml and was setting my textview to show the text as</p>
  
  <pre><code>textView.setText(R.string.text_1);
  </code></pre>
  
  <p>or (if random number was 2)</p>
  
  <pre><code>textView.setText(R.string.text_2);
  </code></pre>
  
  <p>and so on </p>
  
  <p>I observed that the change is just in last character, so tried using reflection</p>
  
  <pre><code>Class c =  Class.forName("com.startpage.mobile.R$string");
  
  Field field = c.getDeclaredField("text_"+num); //num is 1/2/3/4
  System.out.println("********** "+field.get(null));
  </code></pre>
  
  <p>Now the field.get(null) actually return the Id (hexadecimal number in R.java) value instead of string value I would expect. </p>
  
  <p>Is there a way to fetch actual value of string using reflection or this is something in android which I will have to live with?</p>