title: How to allow a custom View's XML attributes to be specified by either resource id or value?
body: <p>I am implementing my own custom DialogPreference subclass, like so:</p>
  
  <pre><code>public class MyCustomPreference extends DialogPreference
  {
      private static final String androidns = "http://schemas.android.com/apk/res/android";
  
      private String mDialogMsg;
  
      public MyCustomPreference(Context context, AttributeSet attrs)
      {
          super(context, attrs);
  
          mDialogMsg = attrs.getAttributeValue(androidns, "dialogMessage");
  
          ...
      }
  
      ...
  }
  </code></pre>
  
  <p>As you can see, I get the <code>dialogMessage</code> XML attribute and save it in the member variable <code>mDialogMsg</code>.</p>
  
  <p><strong>My problem is:</strong> my current code does not allow for the <code>dialogMessage</code> XML attribute to be specified as a string resource id in the XML. </p>
  
  <p>In other words, this works:</p>
  
  <pre><code>android:dialogMessage="Hello world!"
  </code></pre>
  
  <p>But this doesn't:</p>
  
  <pre><code>android:dialogMessage="@string/hello_world"
  </code></pre>
  
  <p>If I specify it as a resource id in the XML, the resource <em>id</em> gets saved to <code>mDialogMsg</code>, not the string resource itself. Now, I know I could do:</p>
  
  <pre><code>context.getString(attrs.getAttributeValue(androidns, "dialogMessage"))
  </code></pre>
  
  <p>But then the user would not be able to enter a normal string in the XML (i.e. a non-resource id). I want to give the user the option of doing both. How do I do this?</p>