현재 비밀번호 두개를 입력했을떄 서로 비교해서 만드는 코드를 작성 중인데 이상하게 반복해서 비밀번호를 입력하는 TextInputLayout에서 setError를 작동시 에러메세지는 안뜨고 언더라인만 빨갛게 변합니다.
RelativeLayout안에
<android.support.design.widget.TextInputLayout
android:id="@+id/pwWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/StyledTilEditTextLayout"
app:hintTextAppearance="@style/StyledTilEditTextFloatingLabel"
app:errorTextAppearance="@style/error_appearance"
android:theme="@style/Theme.AppCompat"
>
<EditText
android:id="@+id/pwTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="password"
android:textColor="#ffffff"
style="@style/StyledTilEditText"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/repeatPwWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/StyledTilEditTextLayout"
app:hintTextAppearance="@style/StyledTilEditTextFloatingLabel"
app:errorTextAppearance="@style/error_appearance"
android:theme="@style/Theme.AppCompat"
>
<EditText
android:id="@+id/repeatPwTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="repeat password"
android:textColor="#ffffff"
style="@style/StyledTilEditText"
/>
</android.support.design.widget.TextInputLayout>
로 배치해놓고 OnCreate 함수안에서
RelativeLayout.LayoutParams rePw = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
rePw.addRule(RelativeLayout.BELOW, R.id.relativeLayout);
rePw.addRule(RelativeLayout.CENTER_HORIZONTAL);
rePw.setMargins(0, (int) ((myApp.getDeviceHeight() - myApp.getStatusBarHeight()) * 0.5) - myApp.getdHeight() * 2, 0, 0);
rePw.width = myApp.getDeviceWidth() - myApp.getdWidth() - myApp.getdWidth();
mPwTextInputLayout.setLayoutParams(rePw);
RelativeLayout.LayoutParams reRePw = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
reRePw.addRule(RelativeLayout.BELOW, R.id.pwWrapper);
reRePw.addRule(RelativeLayout.CENTER_HORIZONTAL);
float d = this.getResources().getDisplayMetrics().density;
int margin = (int)(5 * d);
reRePw.setMargins(0, margin, 0, 0);
reRePw.width = myApp.getDeviceWidth() - myApp.getdWidth() - myApp.getdWidth();
reRePw.height = myApp.getdHeight()*2;
mRepeatPwTextInputLayout.setLayoutParams(reRePw);
이런식으로 두개의 TextInputLayout을 프로그래밍으로 배치시킵니다.
그리고
boolean checkPwValidation(){
if(mPwTxt.getText().toString().length()<7){
mPwTextInputLayout.setErrorEnabled(true);
mPwTextInputLayout.setError("Use at least 7 characters");
return false;
}
return true;
}
void clickedSignUpBtn(){
if(!checkPwValidation()){
return;
}
if(mPwTxt.getText().toString() != mRepeatPwTxt.getText().toString()){
mRepeatPwTextInputLayout.setErrorEnabled(true);
mRepeatPwTextInputLayout.setError("These passwords don't match. Try again");
}else{
mRepeatPwTextInputLayout.setError(null);
mPwTextInputLayout.setError(null);
mRepeatPwTextInputLayout.setErrorEnabled(false);
mPwTextInputLayout.setErrorEnabled(false);
}
}
작동시키는데
이런식으로 빨간 라인만 생기고 에러메세지가 보이지 않습니다.
어느 부분이 문제인건가요?