Material-SearchView

Additional

Language
Java
Version
N/A
Created
Dec 19, 2015
Updated
May 8, 2017 (Retired)
Owner
VyacheslavShmakin
Contributors
VyacheslavShmakin
needsst
2
Activity
Badge
Generate
Download
Source code

Promotion

Material-SearchView

SearchView library based on DialogFragment

Download

Gradle:

compile 'com.github.VyacheslavShmakin.material-searchview:1.1.3'

Maven:

<dependency>
    <groupId>com.github.VyacheslavShmakin</groupId>
    <artifactId>material-searchview</artifactId>
    <version>1.1.3</version>
    <type>aar</type>
</dependency>

Usage

In Code

SearchView searchView = SearchView.getInstance(this);
DataAdapter adapter = new DataAdapter(this, getItems());
searchView.setSuggestionAdapter(adapter);
searchView.setOnVisibilityChangeListener(this);
searchView.setQuery("queryTest", false);

SearchView should be called by using your menu item:

...
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.yourItemId:
            return searchView.onOptionsItemSelected(getFragmentManager(), item);
        default:
            return super.onOptionsItemSelected(item);
    }
}
...