Custom From-To AlertDialog
<p>i need a little help. I've  built an custom alert dialog that contains two date pickers(from - to).I'am inflating the layout for the alert from xml file,and when i'am trying to get the date values my program cashes.Here is the code:</p>

<pre><code>         View fromToLayout = (View)getLayoutInflater().inflate(R.layout.from_to_layout, null);
         final DatePicker fromPicker  = (DatePicker) findViewById(R.id.dpFrom);
         final DatePicker toPicker  = (DatePicker) findViewById(R.id.dpTo);

        AlertDialog alert =  new AlertDialog.Builder(context).create();

           alert.setMessage("Insert Interval:");                
           alert.setView(fromToLayout,0,0,0,20);
           alert.setButton(DialogInterface.BUTTON_POSITIVE,"Ok", new DialogInterface.OnClickListener() 
           {

               @SuppressWarnings("deprecation")
                public void onClick(DialogInterface dialog, int which) 
                   {
                    // TODO Auto-generated method stub

                      Date  dateFrom = new Date(fromPicker.getYear()-1990, fromPicker.getMonth(),fromPicker.getDayOfMonth());
                      Date  dateTo =  new Date(toPicker.getYear() - 1990,toPicker.getMonth(),toPicker.getDayOfMonth());

                      SimpleDateFormat isoFormat = new SimpleDateFormat("yyyyMMdd",Locale.US);
                      SimpleDateFormat dispalyFormat =  new SimpleDateFormat("dd-MM-yyyy",Locale.US);

                      String fromDisplay =  dispalyFormat.format(dateFrom);
                      String toDisplay =  dispalyFormat.format(dateTo);
                      String fromValue = isoFormat.format(dateFrom);
                      String toValue = isoFormat.format(dateTo);

                      CashInInfoActivity.this.setTitle("Cash In " + fromDisplay + " - " + toDisplay );                      
                      DownloadCashInAsyncTask task =  new DownloadCashInAsyncTask(context);
                      task.execute(fromValue,toValue);

                      return;
                   }
            });

           alert.setButton(DialogInterface.BUTTON_NEGATIVE,"Cancel", new DialogInterface.OnClickListener()
           {

            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                return;
                }
            });

           alert.show();
</code></pre>

<p>I get nullPointerException at line :  <code>Date  dateFrom = new Date(fromPicker.getYear()-1990, fromPicker.getMonth(),fromPicker.getDayOfMonth());</code></p>

<p>Log: </p>

<pre><code>12-06 11:01:48.919: E/AndroidRuntime(24121): FATAL EXCEPTION: main
12-06 11:01:48.919: E/AndroidRuntime(24121): java.lang.NullPointerException
12-06 11:01:48.919: E/AndroidRuntime(24121):    at com.example.denandroidapp.CashInInfoActivity$1.onClick(CashInInfoActivity.java:98)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at android.os.Looper.loop(Looper.java:123)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at android.app.ActivityThread.main(ActivityThread.java:3687)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at java.lang.reflect.Method.invokeNative(Native Method)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at java.lang.reflect.Method.invoke(Method.java:507)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-06 11:01:48.919: E/AndroidRuntime(24121):    at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>Do you know what i'am doing wrong?thx</p>
