AutoCompleteTextView NullPointer Exception
<p>I have searched a long time and cannot find a solution to my problem. I am trying to create a Dialog with an AutoCompleteTextView. I followed the tutorial on the Android developer website, and it worked great. I have been successful using layouts on Dialogs before, so I thought this would be just as easy. I created a layout for my Dialog and I made sure that the AutoCompleteTextView has an ID. Here's where the interesting stuff happens...</p>

<pre><code> dialog.setContentView(R.layout.auto_layout);       
 AutoCompleteTextView auto_tv = (AutoCompleteTextView)findViewById(R.id.role_ac);
</code></pre>

<p>Here is the layout as well.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"&gt;
  &lt;TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Role" /&gt;
    &lt;AutoCompleteTextView android:id="@+id/role_ac" android:layout_width="280dip" android:layout_height="wrap_content"/&gt;
    &lt;Button android:layout_height="wrap_content"
        android:layout_width="fill_parent" android:text="Done"
        android:id="@+id/auto_doneButton" /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>For some reason, auto_tv is null even though it does exist in the layout auto_layout. The only way I have been able to get an AutoCompleteTextView in a Dialog is by building the layout programmatically. Why is the AutoCompletTextView null when I try to use it? Did I forget something in my layout or am I not constructing the object correctly? Any help on this would be greatly appreciated. Thanks.</p>
