Null Pointer Exception in Dialog for Android
<p>I am trying to get a return value from a dialog and keep getting a NPE.  I have an Activity that has a button on screen.  When the button is clicked it brings up a modal with a few fields to be filled out.  When I try to get the information back to the main Activity my NPE blows up.  Here is the code: </p>

<pre><code>public class FilterActivity extends Activity {
    final Context context = this;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_filter);

        Button addFilter = (Button) findViewById(R.id.addFilter);
        addFilter.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {

                final EditText et = (EditText) findViewById(R.id.filterName);               
                LayoutInflater inflater = LayoutInflater.from(context);
                View dialog_layout = inflater.inflate(
                        R.layout.dialog_create_filter, null);
                AlertDialog.Builder db = new AlertDialog.Builder(
                        FilterActivity.this);
                db.setView(dialog_layout);

                db.setTitle("Create Filter");
                db.setPositiveButton("OK",
                        new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface d, int which) {     
                                et.getText().toString();
                            }
                        });
                db.show();
            }
        });
      }
    }
</code></pre>

<p>The EditText (et) is still null when I try to get the value out of it.  What am I doing wrong?  Thanks.</p>
