TextInputLayout对在EditText中以编程方式提供提示无效 [英] TextInputLayout has no effect for giving hint programmatically in EditText

查看:84
本文介绍了TextInputLayout对在EditText中以编程方式提供提示无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个EditText,它的父级是TextInputLayout. 我正在尝试以编程方式为EditText提供提示(不在布局中) 在这种情况下,文本输入提示动画不起作用,它的工作方式类似于简单的EditText.有人可以建议如何处理它.

I have an EditText and it's parent is TextInputLayout. I am trying to give hint programmatically for EditText, (not in layout) in this case Text input hint animation is not working, it's working like simple EditText. can some one suggest how to handle it.

下面是我的布局.

<android.support.design.widget.TextInputLayout
    android:id="@+id/text_input_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/post_EditTextPostAnAd"
        style="@style/abc_EditView" />

</android.support.design.widget.TextInputLayout>

推荐答案

您必须将提示设置为 TextInputLayout 这是代码.

You have to set hint to TextInputLayout Here is the code.

TextInputLayout textInputLayout = (TextInputLayout)findViewById(R.id.text_input_layout);
textInputLayout.setHint("Hello");

已更新

在科特林:

val textInputLayout = findViewById(R.id.text_input_layout)
textInputLayout.hint = "Hello"

这篇关于TextInputLayout对在EditText中以编程方式提供提示无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆