Tuesday, June 21, 2011

[android-developers] onDateSet never gets called

Hi,
I'm trying to do an DatePickerDialog with two buttons. My problem is
that onDateSet never gets called.

DatePickerDialog dialogoFecha = new DatePickerDialog(this,
mDateSetListener , mYear, mMonth, mDay);

The Buttons:

dialogoFecha.setButton("PONER FECHA", new
DialogInterface.OnClickListener(){

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Log.d("PRUEBA","Han pulsado al boton OK");
Log.d("PRUEBA", "EL VALOR de mYear es ......." + mYear);
if ( mYear > c.get(Calendar.YEAR)) {
Toast.makeText(getApplicationContext(),"FECHA IMPOSIBLE",
Toast.LENGTH_LONG).show();
mYear = c.get(Calendar.YEAR);
}
}
});

dialogoFecha.setButton2("CANCELAR", new
DialogInterface.OnClickListener(){

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText( getApplicationContext(),"no se puede cancelar",
Toast.LENGTH_LONG).show();
}
});

The DataSet:

private DatePickerDialog.OnDateSetListener mDateSetListener = new
DatePickerDialog.OnDateSetListener() {
//ESTE ES UN LISTENER CREADO -LLAMADO MDATELISTENER- QUE
DEBE TENER EL MODULO ONDATASET PARA
//CUANDO SE CAMBIEN LOS DATOS ACTUALIZAR LAS VARIABLES MYEAR,
MMONT Y MDAY.
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
Log.d("PRUEBA","Entramos en el listener");
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
}
};

Could you help me please?
Many thanks,

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment