Android: How to make an AutoCompleteTextView SingleLine?

15,828

Solution 1

Set android:imeOptions="actionNext" in AutoCompleteTextView in xml .

Solution 2

Setting android:inputType="text" on the AutoCompleteTextView element in the layout XML worked for me; limits input to one line and the Next soft key is present. Pressing the Next soft key didn't actually advance input to the next AutoCompleteTextView in my Activity until I also added android:imeOptions="actionNext".

I couldn't find anything in the reference site to support this, but Content Assist in Eclipse seems to indicate android:singleLine is deprecated (at least in this context):

Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. * Deprecated: This attribute is deprecated. Use "maxLines" instead to change the layout of a static text, and use the "textMultiLine" flag in the inputType attribute instead for editable text views (if both singleLine and inputType are supplied, the inputType flags will override the value of singleLine). [boolean]"

Solution 3

Just add this two below lines. It will be fine.

android:imeOptions="actionNext"
android:inputType="text"

or,

android:imeOptions="actionDone"
android:inputType="text"

Solution 4

I had same issue with My AutoCompleteTextView. It was working fine before android:singleLine="true" deprecated. But once i set android:maxLines="1",it is not worked until i put android:inputType="text"

AutoCompleteTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxLines="1"
    android:inputType="text"
    android:imeOptions="actionNext"
    />

by placing android:inputType="text" on the AutoCompleteTextView it worked for me.

may help you guys :)

Share:
15,828
Archie.bpgc
Author by

Archie.bpgc

Updated on June 06, 2022

Comments

  • Archie.bpgc
    Archie.bpgc almost 2 years
        <AutoCompleteTextView
            android:id="@+id/product"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="product"
            android:singleLine="true"
            android:textColor="@color/white"
            android:textSize="15dp" />
    

    this is my code for AutoCompleteTextView.

    The problem is I want to type in some text and then click Next on the soft-keyboard. Next is not appearing on the soft-keyboard but its not taking cursor to the next EditText. In the same screen rest all EditText have the same code and they work fine. Is AutoCompleteTextView any different from normal EditText in such case??

  • Archie.bpgc
    Archie.bpgc over 11 years
    fine it works. But what is wrong with android:singleLine="true". which worked fine for EditText?
  • Prabs
    Prabs about 7 years
    we need inputType along with imeOptions as @EvanB mentioned
  • ban-geoengineering
    ban-geoengineering almost 7 years
    Using android:inputType="text" and android:imeOptions="actionNext" works for me, but when I click the Next button, I'm not taken to the next view. Is there anything I need to add to the next view?