Binoy Babu Binoy Babu - 5 months ago 37
Android Question

Disabling SearchView

I'm trying to disable a

SearchView
from my
Activity
. I tried the following code :

mSearchView.setEnabled(false);
mSearchView.setFocusable(false);
mSearchView.setClickable(false);


But it does not work. SearchView can still be clicked and KeyBoard popps up. I want it to become greyed out and unclickable. How can I accomplish this?

Answer

To disable any view (e.g. SearchView) either set its input-type to none in layout XML or call view.setInputType(InputType.TYPE_NULL) from the Activity.