如何在 SearchView 中显示搜索结果

How to show the search results in SearchView

我使用工具栏搜索视图。我使用代码捕获输入结果:

SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {

            return true;
        }

当我得到结果时,我正在我的 excel 文件中寻找相似的字符串。然后我return ArrayList(搜索结果)。现在我需要在 SearchView 中显示结果。我该怎么做?

您需要使用与您的搜索视图关联的 CursorAdapter。

Searchview.setSuggestionAdapter

对 link 从数组 (Create a cursor from hardcoded array instead of DB) 中使用游标有帮助。