title: findViewById(int) returns null for custom views, but not Android built-ins
body: <p><strong>The Situation:</strong> I have some custom components in my layout. I have a common layout frame that I load in my Activity base class's <code>onCreate()</code>, and then load my content layouts in my implementations using an inflater, setting the root to the content column of the main layout.</p>
  
  <p><strong>The Problem:</strong> When I grab a reference to the Views, to actually extract the user's input, <code>Activity.findViewById()</code> returns <code>null</code>. It is perhaps a clue that the CheckBox and Button I have in the layout do NOT return <code>null</code>; I get a valid reference to the widget.</p>
  
  <p><strong>Things I've Tried:</strong> I know I am properly loading and inflating the layout xml, because everything shows up, and the standard Views in the same layout can be found by ID. I can interact with my Views and put content into them and everything, but I can't get a reference to them in my code.</p>
  
  <p>I have tried cleaning the project, multiple times. <code>R.id</code> is fresh and up-to-date.</p>
  
  <p>I have checked the Console and Error Log, and there's no UI/XML errors reported.</p>
  
  <p>I tried getting a handle to the root layout of the content I loaded for this activity, and calling <code>View.findViewById()</code> to get my references, and that returns <code>null</code>, too. If I examine the layout in the debugger, I can drill down and find my Views in <code>mChildren</code>.</p>
  
  <p><strong>Perhaps another clue:</strong></p>
  
  <pre><code>public VideoChooser(Context pCtxt, AttributeSet pAttrs)
  {
      super(pCtxt, pAttrs);
      Log.d("VideoChooser", "Expected ID: " + R.id.vchShareVids + " | actual: " + getId());
  }
  </code></pre>
  
  <p>will result in the following output:</p>
  
  <p><code>DEBUG/VideoChooser(10372): Expected ID: 2131296271 | actual: 268435456</code></p>
  
  <p>The ID assigned to the View doesn't match the ID in <code>R.id</code>! Why would that be? I know it's loading the <code>android:id</code> attribute, or else it would be -1 (<code>View.NO_ID</code>).</p>
  
  <p><strong>The Common Layout Frame:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:foo="http://schemas.android.com/apk/res/com.foo"
      android:id="@+id/common_frame" android:orientation="vertical"
      android:layout_width="match_parent" android:layout_height="match_parent"&gt;
  
      &lt;!-- top banner --&gt;
      &lt;LinearLayout android:id="@+id/frame_header" android:orientation="horizontal"
          android:layout_height="wrap_content" android:layout_width="match_parent"
          android:layout_marginBottom="16dp"&gt;
  
          &lt;ImageView android:src="@drawable/banner"
              android:layout_width="wrap_content" android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal" android:layout_weight="1" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;!-- content column --&gt;
      &lt;LinearLayout android:id="@+id/frame_content" android:orientation="vertical"
          android:layout_width="match_parent" android:layout_height="wrap_content"
          android:layout_marginLeft="32dp" android:layout_marginRight="32dp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>The Content Layout:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:foo="http://schemas.android.com/apk/res/com.foo"
      android:id="@+id/content_panel" android:orientation="vertical"
      android:layout_width="match_parent" android:layout_height="match_parent"&gt;
  
      &lt;com.foo.view.VideoChooser android:id="@+id/vchShareVids"
          foo:prompt_text="@string/prompt_share_vid" foo:prompt_size="16dp"
          foo:preview_height="80dp"
          android:layout_width="match_parent" android:layout_height="wrap_content"
          android:layout_marginBottom="12dp" android:hapticFeedbackEnabled="true" /&gt;
      &lt;com.foo.view.ContactChooser android:id="@+id/cchRecipients"
          foo:prompt_text="@string/prompt_share_email" foo:prompt_size="16dp"
          foo:preview_lines="3" foo:dialog_title="Pretend you are picking contacts"
          android:layout_width="match_parent" android:layout_height="wrap_content"
          android:layout_marginBottom="12dp" android:hapticFeedbackEnabled="true" /&gt;
      &lt;com.foo.view.TextChooser android:id="@+id/tchDescription"
          foo:prompt_text="@string/prompt_share_description" foo:prompt_size="16dp"
          foo:preview_lines="1" foo:dialog_title="@string/title_msg_chooser_dlg"
          android:layout_width="match_parent" android:layout_height="wrap_content"
          android:layout_marginBottom="12dp" android:hapticFeedbackEnabled="true" /&gt;
  
      &lt;CheckBox android:id="@+id/chkReshare" android:text="@string/prompt_reshare"
          android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:checked="true" android:hapticFeedbackEnabled="true" /&gt;
      &lt;Button android:id="@+id/btnSend" android:text="@string/btn_send"
          android:layout_width="@dimen/btn_width" android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal" android:hapticFeedbackEnabled="true" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Activity Base Class onCreate():</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.common_frame);
  }
  </code></pre>
  
  <p><strong>Activity Implementation onCreate():</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle pState)
  {
      super.onCreate(pState);
      load_content_view(R.layout.content_layout);
  
      ViewGroup tLayout = (ViewGroup)findViewById(R.id.content_panel);
  
      // These all return null
      mCchVideo = (ContentChooser)tLayout.findViewById(R.id.vchShareVids);
      mCchContact = (ContentChooser)tLayout.findViewById(R.id.cchRecipients);
      mCchDescription = (ContentChooser)tLayout.findViewById(R.id.tchDescription);
  
      // These return valid references
      mChkReshare = (CheckBox)findViewById(R.id.chkReshare);
      mBtnSend = (Button)findViewById(R.id.btnSend);
  
      // ...
  }
  
  protected void load_content_view(int pResId)
  {
      LinearLayout tColumn = (LinearLayout)findViewById(R.id.frame_content);
      getLayoutInflater().inflate(pResId, tColumn);
  }
  </code></pre>