Android SearchView onclick

前端 未结 5 1805
迷失自我
迷失自我 2021-02-19 09:03

I have a searchView which looks like this:

private void setupSearchView() {
    mSearchView = (SearchView) getActivity().findViewById(
            R.id.search_vi         


        
5条回答
  •  無奈伤痛
    2021-02-19 09:43

    This will do exactly what you're trying to achieve. setIconified(false) will keep the cross icon at this end of the SearchView so that the user can still cancel the same way as if the magnifying glass was clicked.

    searchView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            searchView.setIconified(false);
        }
    });
    

提交回复
热议问题