Getting Null Pointer when accessing a component from another Class
<p>I have developed a class A which extends Dialog.</p>

<p>I have inflated the class A using the following code:</p>

<pre><code>View layout = inflater.inflate(R.layout.custom_alert, null, false);
</code></pre>

<p>Within the <code>custom_alert</code> layout file , I have added an EditText with <code>android:id="@+id/edit"</code>.</p>

<p>The scenario is like this:</p>

<p>The user clicks on a specific <code>listitem</code> and a dialog opens where the user enters a value (Edit Text).</p>

<p>I have an Activity screen, consider class B which extends Activity.</p>

<p>From the class B, I am calling the class A.</p>

<p>When the user enters the value within the dialog and clicks on the button OK, I need to retrieve the value and store that in the database.</p>

<p>Providing the code snippet below</p>

<pre><code>LayoutInflater inflater = getLayoutInflater();

inflater.inflate(R.layout.custom_dialog, null);


EditText txt = (EditText) findViewById(R.id.edit);

String value = txt.getText().toString();
</code></pre>

<p>But, even after inflating the <code>custom_dialog</code>, I am unable to fetch the text and I am getting null pointer exception.</p>

<p>I am pasting the update code ... still not getting the EditText value , only null</p>

<p>Dialog builder = new Dialog(this)</p>

<p>View view = LayoutInflater.from(SampleScreen.this).inflate(R.layout.custom_alert, null);
builder.setContentView(view);</p>

<p>EditText nameEditTxt = (EditText) view.findViewById(R.id.edit);</p>

<p>String value = nameEditTxt.getText().toString();</p>
