Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to make an AutoCompleteTextView SingleLine?

    <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 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??

like image 438
Archie.bpgc Avatar asked Sep 11 '12 11:09

Archie.bpgc


People also ask

How do I set autocomplete text on Android?

If you want to get suggestions , when you type in an editable text field , you can do this via AutoCompleteTextView. It provides suggestions automatically when the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.

How do I create an AutoCompleteTextView field in XML?

In android, we can create an AutoCompleteTextView control in two ways either manually in an XML file or create it in the Activity file programmatically. First we create a new project by following the below steps: Click on File, then New => New Project. After that include the Kotlin support and click on next.

What is Android Completionhint attribute in AutoCompleteTextView?

Defines the hint view displayed in the drop down menu. Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu.


3 Answers

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

like image 105
Chirag Avatar answered Oct 05 '22 07:10

Chirag


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]"

like image 33
Nobody Special Avatar answered Oct 05 '22 06:10

Nobody Special


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

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

or,

android:imeOptions="actionDone"
android:inputType="text"
like image 43
Shaon Avatar answered Oct 05 '22 06:10

Shaon