# MaterialSearchView **Repository Path**: android_ios_test/MaterialSearchView ## Basic Information - **Project Name**: MaterialSearchView - **Description**: Android Search View based on Material design guidelines. - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-01 - **Last Updated**: 2024-06-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MaterialSearchView Android SearchView based on Material Design guidelines. The MaterialSearchView will overlay a Toolbar or ActionBar as well as display a ListView for the user to show suggested or recent searches. [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MaterialSearchView-green.svg?style=true)](https://android-arsenal.com/details/1/3469) ## Download To add the MaterialSearchView library to your Android Studio project, simply add the following gradle dependency: ```java compile 'br.com.mauker.materialsearchview:materialsearchview:1.0.3' ``` This library is supported with a min SDK of 14. ## Usage To open the search view on your app, add the following code to your layout: ```xml ``` Then, inside your `Activity` get the reference: ```java // Activity: MaterialSearchView searchView = (MaterialSearchView) findViewById(R.id.search_view); ``` To open the search view, simply call the `searchView.openSearch()` method. To close the search view, call the `searchView.closeSearch()` method. You can check if the view is open by using the `searchView.isOpen()` method. **Protip:** To close the search view using the back button, put the following code on your `Activity`: ```java @Override public void onBackPressed() { if (searchView.isOpen()) { // Close the search on the back button press. searchView.closeSearch(); } else { super.onBackPressed(); } } ``` ## Search history and suggestions You can provide search suggestions by using the following methods: - `addSuggestions(String[] suggestions)` - `addSuggestions(ArrayList suggestions)` To remove the search suggestions use: - `clearSuggestions()` The search history is automatically handled by the view, and it can be cleared by using: - `clearHistory()` You can also remove both by using the method below: - `clearAll()` ## Interfaces Currently there are two interfaces that you can use to instantiate listeners for: - `OnQueryTextListener`: This interface handles either QueryTextChange or QueryTextSubmit events inside the MaterialSearchView. - `SearchViewListener`: This interfaces handles the open or close events of the MaterialSearchView. ## Languages The MaterialSearchView supports the following languages: - English (en_US); - Brazillian Portuguese (pt_BR). ## Sample ## Credits This library was created by MaurĂ­cio Pessoa with contributions from: - [Adam McNeilly](http://adammcneilly.com) JCenter version was made possible with help from: - [Eric Cugota](https://github.com/tryadelion) This project was inspired by the [MaterialSearchView](https://github.com/krishnakapil/MaterialSeachView) library by krishnakapil. ## License The MaterialSearchView library is available under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).