두 개의 날짜 선택 도구가 두 개의 별도 편집 텍스트 상자로 들어갑니다. 하나는 출발 날짜이고 다른 하나는 반환 날짜입니다.반환 날짜가 출발 날짜보다 큰지 확인해야합니까?
DepartDate = (TextView) findViewById(R.id.editText1);
ReturnDate = (TextView) findViewById(R.id.editText2);
public void selectDate(View view) { // Function used to set the date
switch(view.getId()) {
case R.id.imageButton1: // Using the first image button to call the first date picker.
DialogFragment newFragment1 = new SelectDateFragment(0); // Giving an index to the date picker so it won't overwrite the textfields
newFragment1.show(getSupportFragmentManager(), "DatePicker");
break;
case R.id.imageButton2: // Using the first image button to call the first date picker.
DialogFragment newFragment2 = new SelectDateFragment(1); // Giving an index to the date picker so it won't overwrite the textfields
newFragment2.show(getSupportFragmentManager(), "DatePicker");
break;
}
}
public void populateSetDate(int year, int month, int day) { // Setting the format of the date and setting where the selected date will be entered to
DepartDate = (TextView) findViewById(R.id.editText1);
DepartDate.setText(month + "/" + day + "/" + year); //Setting the format in which the date will be shown in the textview
}
public void populateSetDate1(int year1, int month1, int day1) {
ReturnDate = (TextView) findViewById(R.id.editText2);
ReturnDate.setText(month1 + "/" + day1 + "/" + year1);
}
public class SelectDateFragment extends DialogFragment implements
DatePickerDialog.OnDateSetListener {
int type;
public SelectDateFragment(int type) {
this.type = type;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar calendar = Calendar.getInstance();
int yy = calendar.get(Calendar.YEAR);
int mm = calendar.get(Calendar.MONTH);
int dd = calendar.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, yy, mm, dd);
}
public void onDateSet(DatePicker view, int yy, int mm, int dd) {
if(type == 0) { //If the first date picker was clicked then call the following function
populateSetDate(yy, mm + 1, dd);
} else if(type == 1) { //If the second date picker was clicked then call the following function
populateSetDate1(yy, mm + 1, dd);
}
}
나는 또한이 : 나는 .. 도움 여기
에 대한
감사를 반환 날짜가 출발 날짜 이후로이 있는지 확인하는 검증 이론을 필요로하는 것은 내 코드입니다 버튼에는 onClickListener가 있습니다. 반환 날짜가 출발 날짜보다 클 경우 버튼을 클릭 취소 할 수있게하려고합니다.
내가 thsi 질문을 게시 한대로, 이런 식으로 뭔가를 시도 할 수 있습니다 http://stackoverflow.com/questions/15038015/how-to-ignore-time-while-checking-date-using-beforedate- 디 – Pragnani