onQueryTextSubmit从未调用

时间:2020-08-23 17:33:47

标签: android android-activity listener

在我的活动中,我有一个正确显示的searchView,但用户提交查询时从不调用侦听器。我做错了什么?

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_container);

    SearchView searchView = (SearchView) findViewById(R.id.search_view);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String query) {
           listPresenter.onSearch(query);
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            listPresenter.onSearch(query);
            return true;
        }
    });

}

1 个答案:

答案 0 :(得分:0)

问题似乎出在return truereturn false内部的onQueryTextChange的{​​{1}}