首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AutoCompleteTextview多行(不是下拉,而是文本框)

问AutoCompleteTextview多行(不是下拉,而是文本框)
EN

Stack Overflow用户
提问于 2013-12-26 09:01:47
回答 3查看 7.4K关注 0票数 2

我正在使用一台自动完成。我想把这个自动完成显示为一个多行。我不想将下拉列表显示为多行,但我想将文本框显示为多行。

我还在.xml文件中使用了multiline属性,但是它在键盘上显示了nextline键,我不想使用用户来按下这个键并继续下一行。

现在发生了什么

我正在输入文本框后,完成空间,它是水平滚动。并在一行中显示所有文本。

我想要什么

假设用户键入并完成textbox的空格后,光标将自动转到下一行,这样用户就可以一次看到所有文本,而无需水平滚动。

这是我的密码。

代码语言:javascript
复制
<AutoCompleteTextView
                android:id="@+id/txtTags"
                android:layout_width="fill_parent"
                android:layout_height="44dip"
                android:layout_marginLeft="12dip"
                android:layout_marginRight="12dip"
                android:background="@drawable/borderforloginedittext"
                android:gravity="center_vertical"
                android:hint="eg: Breakfast, spicy, italian "
                android:inputType="textPersonName|textImeMultiLine"
                android:imeOptions="actionSearch"
                android:paddingLeft="70dp"
                android:scrollHorizontally="false"
                android:verticalScrollbarPosition="right"
                 android:dropDownHeight="fill_parent"
                android:dropDownWidth="match_parent"
                android:textColor="#333333"
                android:textColorHint="#999999"
                android:textSize="16sp" >
            </AutoCompleteTextView>    

我需要一个行动搜索弹劾选项,这样用户就可以按下键盘的搜索键。这就是为什么我不能使用textmultiline,因为它将搜索键替换为下一行键。

请提供一些参考或提示。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-01-06 06:12:36

我没有找到任何答案。因为我想使用imeoption作为actionSearch,然后我希望我的自动完成功能能够像多行EditText那样运行。

因此,我删除actionsearch作为ime选项并放置多行。这不是我想要的,但至少能让我满意50%。

代码语言:javascript
复制
<AutoCompleteTextView
    android:id="@+id/txtTags"
    android:layout_width="fill_parent"
    android:layout_height="44dip"
    android:layout_marginLeft="12dip"
    android:layout_marginRight="12dip"
    android:background="@drawable/borderforloginedittext"
    android:hint="eg: Breakfast, spicy, italian "
    android:inputType="textPersonName|textMultiLine"
    android:paddingLeft="70dp"                
    android:dropDownHeight="fill_parent"
    android:dropDownWidth="match_parent"
    android:textColor="#333333"
    android:textColorHint="#999999"
    android:textSize="16sp" >
</AutoCompleteTextView>    

这段代码为我提供了一个使用多行的选项。

票数 3
EN

Stack Overflow用户

发布于 2013-12-26 09:44:30

在xml中执行以下更改。

代码语言:javascript
复制
<AutoCompleteTextView
            android:id="@+id/txtTags"
    <!--remove below width as fill_parent and set fixed width as per your need-->
            android:layout_width="fill_parent"
            android:layout_height="44dip"
            android:layout_marginLeft="12dip"
            android:layout_marginRight="12dip"
            android:background="@drawable/borderforloginedittext"
            android:gravity="center_vertical"
            android:hint="eg: Breakfast, spicy, italian "
  <!-- please replace textImeMultiLine with textMultiLine.--> 
            android:inputType="textPersonName|textImeMultiLine"
            android:imeOptions="actionSearch"
            android:paddingLeft="70dp"
            android:scrollHorizontally="false"
            android:verticalScrollbarPosition="right"
             android:dropDownHeight="fill_parent"
            android:dropDownWidth="match_parent"
            android:textColor="#333333"
            android:textColorHint="#999999"
            android:textSize="16sp" >
          </AutoCompleteTextView>
票数 2
EN

Stack Overflow用户

发布于 2018-08-13 11:42:07

它如此简单,你只需要设置

代码语言:javascript
复制
android:singleLine="false"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20781991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档