添加的 EditText 不是 TextInputEditText.请改用该课程

EditText added is not a TextInputEditText. Please switch to using that class instead(添加的 EditText 不是 TextInputEditText.请改用该课程)
本文介绍了添加的 EditText 不是 TextInputEditText.请改用该课程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 TextInputLayout 中使用 EditText,但是在将支持库升级到 23.2.0 后,我在 logcat 中收到此警告,这两者有什么区别一个常规的 EditText 和一个 TextInputEditText?我似乎找不到任何文档.

解决方案

我也在想这个,

横向 UI 编辑空名称字段

编辑名称,您可以看到 IME 不会提示您正在编辑的内容.

横向 UI 编辑空的描述字段

编辑描述您可以看到 IME 提示您正在编辑的内容.

布局 XML

这两个字段的区别在于它们的类型EditText VS TextInputEditText.这里重要的是 TextInputLayoutandroid:hint 而不是包装的 EditText,当 TextInputEditText 的几行Java 代码有很大的不同.

名称字段

描述字段

I'm using an EditText inside a TextInputLayout, but after upgrading the support library to 23.2.0, I get this warning in the logcat, What's the difference between a regular EditText and a TextInputEditText? I can't seem to find any documentation for it.

解决方案

I was wondering this too, Daniel Wilson gathered the documentation, but to the untrained eye it doesn't mean much. Here's what it's all about: "extract mode" is referring to the type of view that's shown when the space is too small, for example landscape on a phone. I'm using Galaxy S4 with Google Keyboard as input method editor (IME).

Landscape UI without visible IME

Based on the focus (on Description) you can see TextInputLayout in action pushing the hint outside the editor. Nothing special here, this is what TextInputLayout is supposed to do.

Landscape UI editing empty Name field

Editing the Name you can see that the IME doesn't give you a hint of what you're editing.

Landscape UI editing empty Description field

Editing the Description you can see that the IME gives you a hint of what you're editing.

Layout XMLs

The difference between the two fields is their type EditText VS TextInputEditText. The important thing here is that TextInputLayout has the android:hint and not the wrapped EditText, this is the case when TextInputEditText's few lines of Java code makes a big difference.

Name field

<android.support.design.widget.TextInputLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="Item Name"
    >
    <EditText
        android:id="@+id/name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />
</android.support.design.widget.TextInputLayout>

Description field

<android.support.design.widget.TextInputLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="Item Description"
    >
    <android.support.design.widget.TextInputEditText
        android:id="@+id/description"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        android:minLines="4"
        android:scrollbars="vertical"
        />
</android.support.design.widget.TextInputLayout>

这篇关于添加的 EditText 不是 TextInputEditText.请改用该课程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)