Android SearchView onclick

前端 未结 5 1797
迷失自我
迷失自我 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:31

    I managed to do this in the following way:

    Setup the search view on click listener

    mSearchView.setOnClickListener(this);
    

    Catch the onClick event:

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.searchView:
                mSearchView.onActionViewExpanded();
                break;
        }
    }
    

    In this way the keyboard and search are activated if you click antwhere on the search bar.

提交回复
热议问题