当前位置: 首页 > 知识库问答 >
问题:

textinputlayout的默认文本

鲁华灿
2023-03-14

我正在使用它来显示textinputlayout的旋转器类型的视图,但是我不知道如何设置它的默认值。

            <com.google.android.material.textfield.TextInputLayout
                  
                    style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                
                    app:hintTextColor="@color/primary_color_3">

                    <AutoCompleteTextView
                        android:id="@+id/accType_dropdown"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:backgroundTint="@android:color/transparent"
                        android:inputType="none"
                        android:lineSpacingExtra="5sp"
                        android:textColor="@color/name_primary_color"
                        android:textSize="14sp" />

                </com.google.android.material.textfield.TextInputLayout>

占位符只工作时,它是在焦点模式,所以请建议我一个解决办法

共有2个答案

林鸿飞
2023-03-14

AutoCompleteTextView可以与适配器一起工作。

只是举个例子:

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/til"

创建适配器:

    ArrayList<String> items = new ArrayList<>();
    items.add("Material");
    items.add("Design");
    items.add("Components");

    ArrayAdapter<String> adapter = new ArrayAdapter<>(this,R.layout.item, items);
    TextInputLayout textInputLayout = findViewById(R.id.til);

设置默认值和适配器:

    ((MaterialAutoCompleteTextView) textInputLayout.getEditText()).setText(items.get(1));
    ((MaterialAutoCompleteTextView) textInputLayout.getEditText()).setAdapter(adapter);
岳俊雅
2023-03-14

AutoCompleteTextView上使用Android:text属性,如下所示

<com.google.android.material.textfield.TextInputLayout
                  
                    style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                
                    app:hintTextColor="@color/primary_color_3">

                    <AutoCompleteTextView
                        android:id="@+id/accType_dropdown"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Select Something"
                        android:backgroundTint="@android:color/transparent"
                        android:inputType="none"
                        android:lineSpacingExtra="5sp"
                        android:textColor="@color/name_primary_color"
                        android:textSize="14sp" />

                </com.google.android.material.textfield.TextInputLayout>
 类似资料:
  • 原文:Text properties and layout 基本的默认字体由一系列rcParams参数控制: rcParam 用法 'font.family' 字体名称或{'cursive', 'fantasy', 'monospace', 'sans', 'sans serif', 'sans-serif', 'serif'}的列表 'font.style' 默认字体,例如'normal','i

  • 我如何从容器到达我的宿主PostgreSQL.conf?或者在哪里可以看到默认的?一位同事给了我他的配置文件,让我把它和我自己的文件进行比较,看看我需要做的一些更改。 容器上的文件路径为: 但我不知道如何将文件从容器拿到我的主机

  • 我使用的是带有AppCompatEditText的TextInputLayout,它为AppCompatEditText提供了一个基于xml形状的自定义背景。每当我设置一些错误,错误线从布局的开始。有没有办法给那个错误行做填充。

  • 在angularJs中,我有一个输入文本框,如何设置默认值?我尝试了但失败了。

  • 问题内容: 无法找到文档中的默认值 https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/query-dsl- minimum-should- match.html 是还是,还是取决于查询是否具有正义或上下文? 问题答案: 默认值取决于查询和上下文: :在查询上下文中且单独存在(否或) :在过滤器上下文中(例如,在查询

  • 问题内容: 在我的应用程序中,我有用和注释的bean 。您可能会猜到:)第一个用于连接到生产数据库的bean,第二个注释使用伪造的DB(或其他)的bean,以加快开发速度。 我想要的是默认配置文件(),如果未被“ something-else ” 覆盖,它将始终使用。 完美将是在我的: 然后用覆盖它,这样我就可以做到: 但是可悲的是这是行不通的。知道我怎么能做到吗?我无法在所有环境上进行设置。 问

  • 在我的应用程序中,我有用和注释的bean。第一个,你可以猜到:),用于连接到生产数据库的bean,第二个注释使用一些假数据库(或其他任何东西)的bean,以使开发更快。 我想要的是默认配置文件(),如果它不被"某物"覆盖,它将始终使用。 在我的: 然后用覆盖它,这样我就可以: 但可悲的是,这是行不通的。你知道我怎么能做到吗?设置在我的所有环境中都不是一个选项。

  • 我目前正在使用vscode和apachepoi,创建了一个程序来自动创建<code>。xlsx编程并让A1单元输入一个名为“Tester”的字符串,然后弹出错误。 我程序中的代码: 错误代码: 嗯.xml( Apache POI对我来说是新的,请帮助我,我会非常感激,非常感谢。