데이터를 제출하기 전에 사용자 입력에 일련의 인증을 적용하고 있습니다. 각 검증은 실패 할 경우 사용자에게 대화 상자를 표시합니다.계속할 수있는 Android EditText 유효성 확인
if (check_1() == false) {
popup(MSG_1);
return false;
}
if (check_2() == false) {
popup(MSG_2);
return false;
}
...
내 문제는 내가 아래 check_2
같이, 사용자가 재정의 할 수있는 검증 한 것인지입니다 :
if (check_1() == false) {
popup(MSG_1);
return false;
}
if (check_2() == false) {
boolean res = popup_with_override(MSG_2); // confirmation dialog
if (res == false)
return false;
// otherwise continue with the validation tests
}
if (check_3() == false) {
popup(MSG_3);
return false;
}
...
나는 아래의 클래스와 같은 확인 대화 상자를 사용하려고하지만,하지 하나씩 검증 된 테스트 목록 아이디어에 잘 맞지 않습니다. 다른 검증에서 재정의 검증을 분리 같은 : 경고 대화 상자가 안드로이드에 차단되지 않기 때문에
public abstract static class DialogCallback implements DialogInterface.OnClickListener, Runnable {
public DialogCallback(Context c, String q) {
AlertDialog.Builder builder = new AlertDialog.Builder(c);
builder.setMessage(q)
.setPositiveButton("Yes", this)
.setNegativeButton("No", this);
builder.create().show();
}
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == DialogInterface.BUTTON_POSITIVE) {
mWhich = DialogInterface.BUTTON_POSITIVE;
run();
} else {
mWhich = DialogInterface.BUTTON_NEGATIVE;
run();
}
}
//
public int mWhich;
}
, 나는 접근 방식은 다시 할 수 있다고 생각?
아이디어가 있으십니까?
1) 내 체크 기능이 더 이상 부울 반환하지 않습니다 : 그것은 다른 사람을 도울 수 있다면