I am doing an application where for example when i click on the image(it is a searchView)
TL;DR: Simply setting the EditText
's hint to the empty string is enough to remove the hint icon.
I found an answer that actually works. There's a lot of stuff on changing the icon using reflection - such as discussed at Styling the ActionBar SearchView. This website IS a great resource, but unfortunately the search hint ImageView
does not change (even though the reflection does not cause errors). The only way that I was able to remove this image was this:
try {
int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
EditText searchPlate = (EditText) searchView.findViewById(searchPlateId);
searchPlate.setHint("");
}
catch (Throwable t)
{
t.printStackTrace();
}
You should place this in your onCreateOptionsMenu
method, and get a reference to your XML
-declared SearchView
using something like:
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();