Search Input View

LAST EDIT Apr 08 2021

SearchInputView is a widget that provides a user interface for the user to enter a search query and submit it:

SearchInputView

Adding the layout

Copied!
1
2
3
4
<io.getstream.chat.android.ui.search.SearchInputView 
    android:id="@+id/searchInputView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" />

Handling User Interactions

Copied!

It is possible to listen for query text changes within the SearchInputView, by using listeners:

1
2
3
4
5
6
7
8
9
searchInputView.setContinuousInputChangedListener { 
    // Search query changed 
} 
searchInputView.setDebouncedInputChangedListener { 
    // Search query changed and has been stable for a short while 
} 
searchInputView.setSearchStartedListener { 
    // Search is triggered 
}
1
2
3
4
5
6
7
8
9
searchInputView.setContinuousInputChangedListener(query -> { 
    // Search query changed 
}); 
searchInputView.setDebouncedInputChangedListener(query -> { 
    // Search query changed and has been stable for a short while 
}); 
searchInputView.setSearchStartedListener(query -> { 
    // Search is triggered 
});

A full list of available listeners to set can be found here.

The search query can be also updated programmatically:

1
2
3
4
// Update the current search query programmatically 
searchInputView.setQuery("query") 
// Clear the current search query programmatically 
searchInputView.clear()
1
2
3
4
// Update the current search query programmatically 
searchInputView.setQuery("query"); 
// Clear the current search query programmatically 
searchInputView.clear();