Android MultiAutoCompleteTextView is an editable text view, extending AutoCompleteTextView, that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing.
You must provide a MultiAutoCompleteTextView.Tokenizer to distinguish the various substrings.
Some important xml attributes of Android MultiAutoCompleteTextView are explained as follows:
|android:completionHint||Specify the hint displayed in the drop down menu.|
|android:completionHintView||Specify the hint view displayed in the drop down menu|
|android:completionThreshold||Specify the number of characters that the user must type before completion suggestions are displayed in a drop down menu|
|android:dropDownAnchor||This is the View to anchor the auto complete dropdown to.|
|android:dropDownHeight||Specify the basic height of the dropdown.|
|android:dropDownHorizontalOffset||The amount of pixels by which the drop down should be offset horizontally|
|android:dropDownSelector||This is the selector in a drop down list|
|android:dropDownVerticalOffset||The amount of pixels by which the drop down should be offset vertically.|
|android:dropDownWidth||This specifies the basic width of the dropdown.|
Android provides several text decorating attributes like Typeface, font family, text style, text size, text color, text shadow etc. that can be applied to AutoCompleteText. To learn more visit below given link:
To customize suggestion box, i created a new layout as given below:
When I created adapter to handle AutoCompleteTextView data, I just specified the layout & TextView which I want for suggestion box as follows:
In this example, we are going to use demonstrate AutoCompleteTextView with customized suggestion box.
Step 1: Create a new project in Android Studio and name it Android AutoCompleteTextView.
Step 2: Open res -> layout -> activity_main.xml and add following code
Step 3: Open res -> values -> strings.xml and replace it with below given code.
Step 4: Create a new layout resource under res -> layout named hint_completion_layout.xml. Replace the code of hint_completion_layout.xml with below given code.
Step 5: Open your MainActivity.java and replace it's code with below given code of f my MainActivity.java as follows:
Step 6: Clean and run the project to see the result.