可过滤的searchview上的大黑盒子

时间:2017-02-24 00:28:20

标签: android listview search searchview toast

我正在关注本教程,我在可过滤的searchview上看到了一个很大的黑盒子。几乎像吐司。知道它是什么以及如何摆脱它?我搜索了开发人员文档,但找不到任何相关信息。当我删除部分onQueryTextChange时,它会完全停止过滤。许多亲切的问候

http://www.coderzheaven.com/2013/06/01/create-searchview-filter-mode-listview-android/

enter image description here

参见代码:

    SearchView search = (SearchView) findViewById(R.id.search);
    ListView list = (ListView) findViewById(R.id.listView);

    final String[] mStrings = {"1", "2", "text", "more text", "more text here"};

    list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings));
    list.setTextFilterEnabled(true);
    setupSearchView();

...

private void setupSearchView() {
    search.setIconifiedByDefault(false);
    search.setOnQueryTextListener(this);
    search.setSubmitButtonEnabled(false);
    search.setQueryHint("Search Here");
}

public boolean onQueryTextChange(String newText) {
    if (TextUtils.isEmpty(newText)) {
        list.clearTextFilter();
    } else {
        list.setFilterText(newText.toString());

    }
    return true;
}

public boolean onQueryTextSubmit(String query) {
    return false;
}

0 个答案:

没有答案