0

As a developer, do I have access to android's default search icon? I am referring to the one that comes with the SearchView? Is there a way to access it as I might, for instance, access any drawable that I own? One of the ways I intend to use it is to add it to an AutoCompleteTextView, as I might to any other TextView.

learner
  • 11,490
  • 26
  • 97
  • 169

2 Answers2

0

The search icon is included in the action bar icon package. It has both light and dark versions of it as do all the other icons found there.

Not sure if older android versions use a different icon but you could make sure that they are the same by setting the icon yourself with something like:

getMenuInflater().inflate(R.menu.actionbar_items, menu);

SearchView searchView = menu.findItem(R.id.action_search).getActionView();
int resId = getResources().getIdentifier("search_button", "id", "android");
ImageView searchIcon = (ImageView) mSesearchViewrchView.findViewById(resId);
Simas
  • 43,548
  • 10
  • 88
  • 116
  • Does this mean I have to have a searchView in my menu? or could I just use your `int resId` line and then from there try to load the image? (I am trying different things with your suggestion but so far no result). – learner Oct 06 '14 at 16:46
  • @learner the second part that I suggested is only if you have a SearchView in your app. If you don't, then just use the icon Android provides. The whole reason for the 2nd part is so the icon you use and the SearchView icon are the same (which probably is the case by default but just making sure). – Simas Oct 06 '14 at 16:49
0

Some of them are available via:

   android.R.drawable.bla-bla-bla - from runtime
   @android.drawable.bla-bla-bla - from xml

Or download all icons from: https://developer.android.com/design/downloads/index.html

nister
  • 171
  • 6