Android
Search Result List View
Confused about "Search Result List View"?
Let us know how we can improve our documentation:
LAST EDIT Mar 05 2021
- On This Page:
- Adding the layout
- Binding with a ViewModel
SearchResultListView
is a widget that displays a list of search results:

Adding the layout
Copied!Confused about "Adding the layout"?
Let us know how we can improve our documentation:
1
2
3
4
<io.getstream.chat.android.ui.search.list.SearchResultListView
android:id="@+id/searchResultListView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Binding with a ViewModel
Copied!Confused about "Binding with a ViewModel"?
Let us know how we can improve our documentation:
SeachResultListView
comes with SearchViewModel
which is responsible for providing all needed data. The view can be bound with it using:
1
2
3
4
// Get ViewModel
val viewModel: SearchViewModel by viewModels()
// Bind it with SearchResultListView
viewModel.bindView(searchResultListView, this)
1
2
3
4
// Get ViewModel
SearchViewModel viewModel = new ViewModelProvider(this).get(SearchViewModel.class);
// Bind it with SearchResultListView
SearchViewModelBinding.bind(viewModel, searchResultListView, this);
After the SeachResultListView
is bound to the SearchViewModel
, the search can be triggered with the setQuery
method. In the example below, the search query comes from SearchInputView:
1
2
3
searchInputView.setSearchStartedListener { query ->
viewModel.setQuery(query)
}
1
2
3
searchInputView.setSearchStartedListener(query -> {
viewModel.setQuery(query);
});