first let me say that I’m quite new to Android, so sorry if this question is really simple, but I couldn’t find an answer for it in SO or Google.
I’m doing a small app for training and I I have this datePicker object:
<DatePicker
android:id="@+id/datePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="64dp"
android:calendarViewShown="false"
android:spinnersShown="true"
android:onClick="selectDate" />
So, I’ve set up an onClick connection to a selectDate function I have:
public void selectDate(View view) {
datePick = (DatePicker) findViewById(R.id.datePicker1);
int yy = datePick.getYear();
int mm = datePick.getMonth();
int dd = datePick.getDayOfMonth();
Calendar calendar = Calendar.getInstance();
calendar.set(yy, mm, dd);
int doy = calendar.get(Calendar.DAY_OF_YEAR);
populateDayOfYear(doy);
}
But the app doesn’t do what is expected of it, and in fact after debuging, it never even enters this function.
So, just to be clear, what I want is to update a value (with the doy in the populateDayOfYear(doy)) of a EditText field every time I change a value in my datePicker, I don’t want to press a button and be taken to a DatePickerDialog and only then be able to update the EditText field.
Is it possible with the standard datePicker or do I need to build one by myself?
Try this in OnCreate