title: Android: java.lang.NullPointerException at setText in method
body: <p>Getting NullPointerException at [dateView.setText(tempDate);]...any tips please? Bascially I need to get the changed date from Calendar and then update a TextView with this new date. Thanks.</p>
  
  <pre><code>CalendarView calendar;
  String tempDate;
  TextView dateView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      dateView = (TextView)findViewById(R.id.TextDate);
  
      setContentView(R.layout.calendar);
      initializeCalendar();
  
  }
  
  public void initializeCalendar() {
      calendar = (CalendarView) findViewById(R.id.calendar);
      calendar.setShowWeekNumber(false);
      calendar.setFirstDayOfWeek(2);
      calendar.setSelectedWeekBackgroundColor(getResources().getColor(R.color.lightblue));
      calendar.setUnfocusedMonthDateColor(getResources().getColor(R.color.transparent));
      calendar.setWeekSeparatorLineColor(getResources().getColor(R.color.transparent));
      calendar.setSelectedDateVerticalBar(R.color.blue);
      calendar.setOnDateChangeListener(new OnDateChangeListener() {
          @Override
          public void onSelectedDayChange(CalendarView view, int year, int month, int day) {
              Toast.makeText(getApplicationContext(), day + "/" + month + "/" + year, Toast.LENGTH_LONG).show();
              tempDate = (day+"/"+month+"/"+year);
              dateView.setText(tempDate);
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Error Report:</p>
  
  <pre><code>java.lang.NullPointerException
          at training.mark.trainingii.Calendar$1.onSelectedDayChange(Calendar.java:40)
          at android.widget.CalendarView$1.onChanged(CalendarView.java:1012)
          at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
          at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
          at android.widget.CalendarView$WeeksAdapter.setSelectedDay(CalendarView.java:1375)
          at android.widget.CalendarView$WeeksAdapter.onDateTapped(CalendarView.java:1460)
          at android.widget.CalendarView$WeeksAdapter.onTouch(CalendarView.java:1448)
          at android.view.View.dispatchTouchEvent(View.java:7708)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2329)
          at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1568)
          at android.app.Activity.dispatchTouchEvent(Activity.java:2458)
          at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2277)
          at android.view.View.dispatchPointerEvent(View.java:7893)
          at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3954)
          at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3833)
          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
          at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
          at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
          at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
          at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
          at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
          at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
          at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
          at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
          at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5602)
          at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5582)
          at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5553)
          at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5682)
          at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
          at android.os.MessageQueue.nativePollOnce(Native Method)
          at android.os.MessageQueue.next(MessageQueue.java:138)
          at android.os.Looper.loop(Looper.java:123)
          at android.app.ActivityThread.main(ActivityThread.java:5081)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
          at dalvik.system.NativeStart.main(Native
  </code></pre>