Top Android AutoCompleteTextView Libraries
Top Android AutoCompleteTextView Libraries.
The AutoCompleteTextView is a versatile component in Android that provides suggestions as the user types. However, the built-in implementation of AutoCompleteTextView may not always meet your specific requirements. That's where third-party libraries come in handy. In this tutorial, we will explore some of the popular AutoCompleteTextView libraries for Android and learn how to use them effectively.
1. Material BetterSpinner
Material BetterSpinner is a library that enhances the functionality of the AutoCompleteTextView by providing a more elegant and customizable user interface. It also supports data binding and comes with additional features like error handling.
Installation
Add the following dependency to your app-level build.gradle file:
implementation 'com.weiwangcn.betterspinner:library-material:1.2.8'
Usage
- Add the MaterialBetterSpinner to your XML layout:
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:met_hint="Select an item"
app:met_floatingLabel="normal" />
- Initialize the MaterialBetterSpinner in your Java/Kotlin code:
val spinner = findViewById<MaterialBetterSpinner>(R.id.spinner)
val adapter = ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, items)
spinner.setAdapter(adapter)
2. TokenAutoComplete
TokenAutoComplete is a library that extends the AutoCompleteTextView to support tokenized input. It allows users to enter multiple items separated by tokens, similar to email addresses in Gmail.
Installation
Add the following dependency to your app-level build.gradle file:
implementation 'com.tokenautocomplete:TokenAutoComplete:1.5.2'
Usage
- Add the TokenAutoCompleteTextView to your XML layout:
<com.tokenautocomplete.TokenCompleteTextView
android:id="@+id/tokenAutoCompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
- Initialize the TokenAutoCompleteTextView in your Java/Kotlin code:
val tokenAutoCompleteTextView = findViewById<TokenCompleteTextView>(R.id.tokenAutoCompleteTextView)
val adapter = ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, items)
tokenAutoCompleteTextView.setAdapter(adapter)
3. PlaceCompleteTextView
PlaceCompleteTextView is a library that provides AutoCompleteTextView functionality specifically for searching and selecting places using the Google Places API.
Installation
Add the following dependency to your app-level build.gradle file:
implementation 'com.github.islamkhsh:PlaceCompleteTextView:1.0.0'
Usage
- Add the PlaceCompleteTextView to your XML layout:
<com.islamkhsh.PlaceCompleteTextView
android:id="@+id/placeCompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
- Initialize the PlaceCompleteTextView in your Java/Kotlin code:
val placeCompleteTextView = findViewById<PlaceCompleteTextView>(R.id.placeCompleteTextView)
placeCompleteTextView.setApiKey("YOUR_GOOGLE_PLACES_API_KEY")
Additional Libraries
Here are a few more AutoCompleteTextView libraries you might find useful:
- EasyAutocomplete
- SuggestionDropDownEditText
- Autocomplete Library
- Smarty-Streets-AutoCompleteTextView - Gradle library. Android AutocompleteTextView that receives and displays address suggestions from Smarty Streets..
- ClickDrawableTextView - This library add the ability to listen to drawables touch events for TextView subclasses.
- android-dynamic-autocomplete - A simple library that helps extends AutoCompleteTextView with dynamically loaded data.
- ChipTextViewHelper - Android demo app/library for easy implementation of chip-like text in your TextViews (EditText, AutoCompleteTextView, etc..).
- ViewBuilder - ViewBuilder for Android is a library for easily building useful views like Tags, Spinner, AutoCompleteTextView, ....
Feel free to explore these libraries and choose the one that best suits your project's requirements.
That's it! You now have a good understanding of some of the top AutoCompleteTextView libraries for Android, along with the installation and usage instructions. Happy coding!