title: Create custom component based on LinearLayout, declaring layout in XML
body: <p>I've been trying to create a Compound Control in Android 1.5 (as <a href="http://developer.android.com/guide/topics/ui/custom-components.html#compound" rel="noreferrer">described here</a>) but havn't been able to find any good examples on how to do this using an XML file to specify a layout. I'm fine with creating an Activity and then loading an xml file using the following in the constructor:</p>
  
  <pre><code>setContentView(R.layout.main);
  </code></pre>
  
  <p>However, I want to do this in subclass of LinearLayout - so I can use this compound component in other XML layouts. Something along the lines of:</p>
  
  <pre><code>public class CustomView extends LinearLayout
  {
    public CustomView(Context context) {
         super(context);
         setupView();
    }
    public CustomView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        setupView();
    }
    public void setupView()
    {
      setContentView(R.layout.custom); // Not possible
    }
  }
  </code></pre>
  
  <p>What is the correct way of going about doing this?</p>