How to disable searchview?

后端 未结 10 1760
别那么骄傲
别那么骄傲 2020-12-19 06:10

Can you help me on how to disable searchview when button is pressed? I\'m trying this code:

searchView.setEnabled(false);
                searchView.setFocu         


        
相关标签:
10条回答
  • 2020-12-19 06:50

    You can use:

    searchView.clearFocus();
    

    and if you want to hide it using:

    searchView.setVisibility(View.GONE);
    
    0 讨论(0)
  • 2020-12-19 06:50

    Try below code:

    searchView.setIconified(true);
    
    0 讨论(0)
  • 2020-12-19 06:54

    If you want to clear it (SearchView), do:

    searchView.clearFocus();

    and if you want to hide it temporarily, do:

    searchView.setVisibility(View.GONE);

    0 讨论(0)
  • 2020-12-19 06:56

    Try the following:

    searchview.setInputType(InputType.TYPE_NULL);
    
    0 讨论(0)
  • 2020-12-19 06:59

    This worked for me

    ImageView searchIcon = (ImageView)searchView.findViewById(android.support.v7.appcompat.R.id.search_button);
        searchIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               // Don't perform any action.
            }
        });
    
    0 讨论(0)
  • 2020-12-19 07:01
    searchView.findViewById(R.id.search_button).setEnabled(false);
    

    But you must check it for null and hide searchView:

    ImageView searchBtn = (ImageView) searchView.findViewById(R.id.search_button);
    if (searchBtn != null) searchBtn.setEnabled(false);
    searchView.setVisibility(View.GONE);
    

    I think this will work

    0 讨论(0)
提交回复
热议问题