I upgraded the lib support version to 24.2.0 and my registration screen is already dead. The problem is in TextInputLayout, I have two methods:
protected void setError(@Nullable CharSequence errorMsg, @NonNull EditText editText, boolean forceClean) {
TextInputLayout viewParent = (TextInputLayout) editText.getParent();
if (forceClean) {
viewParent.setErrorEnabled(false);
viewParent.setError(null);
}
viewParent.setErrorEnabled(true);
viewParent.setError(errorMsg);
}
protected void clearError(@NonNull EditText editText) {
TextInputLayout viewParent = (TextInputLayout) editText.getParent();
viewParent.setErrorEnabled(false);
viewParent.setError(null);
}
I get an error when I try to pass the parent EditText element to TextInputLayout, there is such code in the layout for this:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/login_registration_firstname"
style="@style/registration_form_field"
android:hint="@string/login_registration_firstname"
android:inputType="textCapWords" />
</android.support.design.widget.TextInputLayout>
So this worked fine, but now it throws a ClassCastException:
java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.support.design.widget.TextInputLayout
I am wondering if there are any new guidelines in this?
source
share