int year;
int month;
int day;
private void getNowDate() {
Calendar calendar = Calendar.getInstance();
year = calendar.
get(Calendar.YEAR);
month = calendar.
get(Calendar.MONTH);
day = calendar.
get(Calendar.DAY_OF_MONTH);
}
private void showDate(
final int index) {
DatePickerDialog datedialog =
new DatePickerDialog(
this,
new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view,
int year,
int month,
int dayOfMonth) {
if (index ==
1) {
tvStart.setText(
"");
tvStart.setText(year +
"-" + (month +
1) +
"-" + dayOfMonth);
}
if (index ==
2) {
tvEnd.setText(
"");
tvEnd.setText(year +
"-" + (month +
1) +
"-" + dayOfMonth);
}
}
}, year, month, day);
datedialog.show();
}