Question: I have an activity with action bar and one icon on this ActionBar. When user press this icon I need to hide this icon and show EditText with cross to clear text. When user will done with it (choose item in ListView or press back button) I will need to show icon again.

Here is two related question:
1. How to add EditText on ActionBar for ListView filtering?
2. How to change ActionBar between EditText and icon?

Before click:

![enter image description here](https://i.stack.imgur.com/RG1Hq.png)

After click on 'plus' icon:

![enter image description here](https://i.stack.imgur.com/nNVRA.png)

Answer: 
You need to add a SearchView widget to your application.
The official documentation is here:
<http://developer.android.com/training/search/setup.html>

There are also detailed instructions to add it.
> 
> 1. How to add EditText on ActionBar for ListView filtering?
> 
> 
> 

Please refer to [this answer](https://stackoverflow.com/a/11638739/2319390) by Commonsware . More clearly his [sample project](https://github.com/commonsguy/cw-omnibus/tree/master/ActionBar/ActionBarDemo) will do the trick.

> 
> 2. How to change ActionBar between EditText and icon?
> 
> 
> 

Simply override `onOptionItemSelected` and try to set the visibility of that menu item.

```
MenuItem item = menu.findItem(R.id.my_item);
item.setVisible(false);

```

Alternatively , If you want full control in your hands try to [customize your action bar](http://javatechig.com/android/actionbar-with-custom-view-example-in-android)