How to disable searchview?

后端 未结 10 1767
别那么骄傲
别那么骄傲 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 07:10

    SearchView isn't the actual EditText you type into, but rather is a LinearLayout which holds a bunch of views, including the EditText.

    To get the view you actually want for disabling it:

    EditText searchViewEditText = (EditText) searchView.findViewById(R.id.search_src_text);
    

    Note, this only works if you're using support v7 SearchView, since the particular resource id is internal if you use the framework SearchView.

提交回复
热议问题