I am trying to achieve a uniform action bar across my app. I am currently trying to add a search widget. My app displays the magnifying glass, another icon, and the overflow menu icon in its actionbar.
I haven't yet added any search functionality I am just trying to get the icon to display how I want it.
The problem I have is that on my launch page the magnifying glass is displayed, and if clicked the field for entering a search term appears.
If the user then goes to another activity the magnifying glass will still appear in the action bar but if clicked nothing will happen. The only difference is that other activities display the "Up" arrow to the left of the android logo in the action bar but I don't think this is the reason the search widget isn't working.
How can I fix this so the user can enter a search term from any page?
Below is my xml code:
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/search_title"
android:showAsAction="collapseActionView|always"
app:showAsAction="always"
android:actionViewClass="android.widget.SearchView" />
My onPrepareOptionsMenu(), onCreateOptionsMenu() and onOptionsItemSelected() are all identical in every activity and since they work for the main page I believe the problem lies within this xml file.
I would prefer if the search would display always rather than moving into the overflow menu.
Thanks for your time