Skip to content

Instantly share code, notes, and snippets.

@mderazon
mderazon / MainActivity.java
Last active March 13, 2016 01:53
a main activity with the new ClearableAutoCompleteTextView and a method to toggle between the visibility of the the search icon and the search box
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ......
// ......
ActionBar actionBar = getSupportActionBar(); // you can use ABS or the non-bc ActionBar
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME
| ActionBar.DISPLAY_HOME_AS_UP); // what's mainly important here is DISPLAY_SHOW_CUSTOM. the rest is optional
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);