AutoCompleteTextView in Android

AutoCompleteTextView is an editable text view that shows completion suggestions. It provides suggestions automatically when the user is typing. Suggestion will be shown in dropdown from where user can select any item and replace the content of editbox.

User can dismiss dropdown by pressing back button or by selecting any item from the list. Suggestions will be based on the value given in adapter.

If we want to use AutoCompleteTextView, first we need to create it in xml file.

After that create a refrence of AutoCompleteTextView in your Activity/Fragment :

Now we need to set values in adapter for AutoCompleteTextView :

with above code user will be able to get suggetions after writting two letters which is default threshold. If user want suggestions after writting first letter itself, we need to set threshold value to 1.

Click Events in AutoCompleteTextView

Same as ListView here also onItemClickListener will be called when user click on item from dropdown list.

AutoCompleteTextView with custom layout

In above code we have seen basics of AutoCompleteTextView, now we will see how can we use AutoCompleteTextView with custom layout.

create row_item.xml for dropdown row.

create adapter with custom layout, we need to define layout name as well as textview id.


AutoCompleteTextView with custom adapter

First we will create custom model class named


Download source code from Github.

Push Notifications using GCM in Android Studio
Android N UI Leak Reveals Redesigned Notification