【问题标题】:AutoCompleteTextView with keyboard done button and maxLines带有键盘完成按钮和 maxLines 的 AutoCompleteTextView
【发布时间】:2017-02-04 21:30:25
【问题描述】:

我正在尝试使用多行文本和键盘完成按钮来实现 AutoCompleteTextView。但完成按钮不显示在键盘上(显示输入按钮)。我用android:singleLine="true" 尝试过同样的事情,文本与完成按钮成单行。

 <AutoCompleteTextView
                        android:id="@+id/txtVillageName"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/edt_border"
                        android:cursorVisible="true"
                        android:maxLines="4"
                        android:hint="Enter your location"
                        android:imeOptions="actionDone"
                        android:textColor="@color/text_color"
                        android:textColorHint="@color/lblColor"
                        android:textSize="@dimen/text_size_large" />

【问题讨论】:

标签: android android-softkeyboard autocompletetextview


【解决方案1】:

android:imeActionLabel="Done" 添加到您的xml 代码中

<AutoCompleteTextView
        android:id="@+id/txtVillageName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:cursorVisible="true"
        android:hint="Enter your location"
        android:imeOptions="actionDone"
        android:imeActionLabel="Done"
        android:singleLine="true" />

【讨论】:

  • 更新了答案。
【解决方案2】:

android:inputType="text" 有效。

<AutoCompleteTextView
                        android:id="@+id/txtVillageName"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:cursorVisible="true"
                        android:hint="@string/location_hint"
                        android:imeOptions="actionDone"
                        android:inputType="text"
                        android:textColor="@color/text_color"
                        android:textColorHint="@color/lblColor"
                        android:textSize="@dimen/text_size_large" />

设置 Horizo​​ntalScrolling 和 MaxLines

mAutocompleteTextView.setHorizontallyScrolling(false);
mAutocompleteTextView.setMaxLines(Integer.MAX_VALUE);

有效

【讨论】:

    猜你喜欢
    • 2011-02-19
    • 2015-04-06
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-14
    相关资源
    最近更新 更多