title: Having trouble with findViewById - returning null
body: <p>I have the activity_main XML like this:</p>
  
  <pre><code>&lt;LinearLayout ...&gt;
      &lt;EditText android.id="@+id/edit_text"
          android:layout_weight="1"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:hint="@string/edit_message" /&gt;
      &lt;Button android.id="@+id/my_send"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/button_send"
          android:onClick="sendMessage" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The main java codes are:</p>
  
  <pre><code>public class MainActivity extends Activity {
      void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);   
          setContentView(R.layout.activity_main);
          EditText editText = (EditText) findViewById(R.id.edit_text);
          if (editText == null)   
              Log.v("editText", "null editText");
          else
              Log.v("editText", "good editText");
      }
  }
  </code></pre>
  
  <p>The display is correct and I can see the EditText and Button fields. However, I always got NULL for editText. I read the previous problems. Most of them were due to the fact that setContentView(R.layout.active_main) was not used. But I can't find out why I am having problem with my codes. Any help is greatly appreciated.</p>