The App. crashs when DatePickerDialog is called.

Rma_80

New member
Oct 27, 2011
0
0
0
Visit site
Hi guys,
I'm new to this forum and I have a problem with the App. I make.

When I try to call the DatePickerDialog the App crashs, despite, I follow the same way to call the TimePickerDialog, and it works. any Suggestions.
sorry If I posted this question in the wrong forum, if there is a specific forum for such questions please tell me.
Code:
public class PickerActivity extends Activity{

int hour, minute;
int year,month, day;
static final int timePickerId = 0;
static final int datePickerId = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.picker);

    //showDialog(timePickerId); 
    showDialog(datePickerId);
}

@Override    
protected Dialog onCreateDialog(int id) {

    switch (id) {
    /*case timePickerId: 
        return new TimePickerDialog(
            this, mTimeSetListener, hour, minute, true);*/
    case datePickerId:
        return new DatePickerDialog(
            this, mDateSetListener, year, month, day);
}
return null;    
}

private DatePickerDialog.OnDateSetListener mDateSetListener =
        new DatePickerDialog.OnDateSetListener() 
        {
            public void onDateSet(DatePicker view, int Year, int monthOfYear,
                    int dayOfMonth) 
            {
                year = Year;
                month = monthOfYear;
                day = dayOfMonth;
                Toast.makeText(getBaseContext(), 
                        "You have selected : " + (month) +
                        "/" + day + "/" + year,
                        Toast.LENGTH_SHORT).show();
            }
        };