title: How to pass custom component parameters in java and xml
body: <p>When creating a custom component in android it is often asked how to create and pass through the attrs property to the constructor.</p>
  
  <p>It is often suggested that when creating a component in java that you simply use the default constructor, i.e. </p>
  
  <pre><code>new MyComponent(context);
  </code></pre>
  
  <p>rather than attempting to create an attrs object to pass through to the overloaded constructor often seen in xml based custom components. I've tried to create an attrs object and it doesn't seem either easy or at all possible (without an exceedingly complicated process), and by all accounts isn't really required. </p>
  
  <p>My question is then: What is the most efficient way of construction a custom component in java that passes or sets properties that would have otherwise been set by the attrs object when inflating a component using xml?</p>