<android.support.design.widget.TextInputLayout
android:id="@+id/productLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true">
<EditText
android:id="@+id/product"
android:layout_width="match_parent"
android:layout_height="@dimen/margin_padding_width_height_6"
android:cursorVisible="false"
android:drawableRight="@drawable/ic_arrow_down"
android:focusableInTouchMode="false"
android:hint="@string/product"
android:inputType="none"
android:paddingEnd="@dimen/margin_padding_width_height_2"
android:paddingRight="@dimen/margin_padding_width_height_2"
android:singleLine="true"
android:textSize="@dimen/text_size_m" />
private boolean validateFields() {
if (mCategory.getText().toString().isEmpty())
mCategoryLayout.setError("Please select a category");
else if (mProducts.getText().toString().isEmpty())
mProductsLayout.setError("Please select a product");
else if (mSerialNumber.getText().toString().isEmpty())
mSerialNumberLayout.setError("Please enter the serial number");
else
return true;
return false;
}
我已经实现了点击侦听器EditText
,所以我不想浮动EditText
设置错误时将标签置于顶部TextInputLayout
。我该如何禁用它?
从版本 23.2.0 开始,您可以调用支持库
setHintEnabled(false)
或将其放入 TextInputLayout xml 中,如下所示:
app:hintEnabled="false"
尽管这个名称可能会让您认为它删除了所有提示,但它只是删除了浮动提示。
相关文档和问题:http://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#setHintEnabled(boolean) http://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#setHintEnabled(boolean)
https://code.google.com/p/android/issues/detail?id=181590 https://code.google.com/p/android/issues/detail?id=181590
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)