title: Accessing AttributeSet from custom View Java code
body: <p>I have a custom View with several text fields that are drawn on it using onDraw. There are several instances of the View in my Activity. The data for these text fields is stored in a number of string and integer arrays (I stored it in arrays because I will use the data in other parts of the application).</p>
  
  <p>My plan was to have some kind of custom attribute in the XML to pass a single integer, and then access this on the Java side and use it as an index for the arrays. So for example, the text from <code>array1[0]</code>, <code>array2[0]</code>, and <code>array3[0]</code> would be used in the View with the <code>mynamespace:customattribute="0"</code> in its XML.</p>
  
  <p>However, after researching for the better part of four hours, I have concluded that custom attributes on custom Views are basically impossible. The only information I have been able to find either only references the XML, and not how to access it via code, or it does explain the code but refers to an older version of the SDK.</p>
  
  <p>This is driving me batty. If anyone can point me in the right direction, or if you know of another method of doing what I am trying to do, I'd be eternally grateful.</p>
  
  <p>EDIT: I've started trying to do something using <code>android:tag</code>... if I figure out a way to work it, I'll post my answer.</p>
  
  <p>ANOTHER EDIT: I can't answer my own questions yet, so I'll do it here. So I added a <code>tag</code> in the XML and accessed it with <code>getTag()</code>. I cast it as a String, and parsed the integer from that.</p>
  
  <p>I can't <em>believe</em> how simple this was. Sorry for the pointless question....</p>