我得到以下内容。设置错误后,我不希望该框用红色填充。我是使用TextInputLayout的新手。我该如何解决这个问题?
我有以下
<android.support.design.widget.TextInputLayout
android:id="@+id/til_confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/textBoxBottomGap"
android:layout_marginLeft="@dimen/leftRightMargin"
android:layout_marginRight="@dimen/leftRightMargin"
app:hintEnabled="false">
<EditText
android:id="@+id/confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_edittext"
android:hint="Confirm Password"
android:inputType="textPassword"
android:maxLines="1"
android:paddingBottom="5dp"
android:paddingLeft="@dimen/padding"
android:paddingRight="@dimen/padding"
android:paddingTop="5dp"
android:ems="10"
android:textColor="#999999"
/>
</android.support.design.widget.TextInputLayout>
@drawable/rounded_edittext
引用了以下内容。
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="15dp">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="3dp"
android:bottomLeftRadius="3dp"
android:topLeftRadius="3dp"
android:topRightRadius="3dp"/>
<stroke android:width="1dip" android:color="#999999" />
</shape>
我在活动中有以下内容:
if (!newPlainPssd.equals(confirmPlainPssd)) {
etConfirmPassword.requestFocus(); //references editText
tilConfirmPassword.setError("Passwords don't match"); //references TextInputLayout
return;
}
答案 0 :(得分:1)
试试这个
if (!newPlainPssd.equals(confirmPlainPssd)) {
etConfirmPassword.requestFocus(); //references editText
tilConfirmPassword.setError("Passwords don't match"); //references TextInputLayout
text.setError("Nilesh");
editText.setBackgroundColor(Color.TRANSPARENT);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
editText.setBackgroundResource(R.drawable.rounded_edittext);
}
}, 50);
return;
}