Android App crash when setting setOnFocusChangeListener to EditText
<p>My app keep crashing when i set OnFocusChangeListener to editText.. the app crashing and i logcat send me java.lang.nullPointerException..why?</p>

<pre><code>public class MainActivity extends FragmentActivity 
    implements HeadlinesFragment.OnHeadlineSelectedListener {
 private int myYear, myMonth, myDay;
 static final int ID_DATEPICKER = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.news_articles);
    EditText txt1 = (EditText) findViewById(R.id.editText2);
    txt1.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
             final Calendar c = Calendar.getInstance();
             myYear = c.get(Calendar.YEAR);
             myMonth = c.get(Calendar.MONTH);
             myDay = c.get(Calendar.DAY_OF_MONTH);
             showDialog(ID_DATEPICKER);
        }
      });
</code></pre>
