Can anyone please help in how to add a button to the expanded SearchView (placed in ActionBar) below the list of recent search suggestions the SearchView is showing?
Since SearchView extends LinearLayout, I have tried to add a button in the layout, but I am not able to place it below the expanded suggestions list.
I made a vertical linearlayout called 'mysearch' with a SearchView and a button below it. Then I also referred to it in android:actionLayout="@layout/mysearch" in
menu.xml` for ActionBar.
I try to get a reference to SearchView in onCreateOptionsMenu
of my activity by using
SearchView searchView =
(SearchView)menu.findItem(R.id.menu_search).getActionView();
When I run it, I get a ClassCastException:cannot convert LinearLayout to SearchView
, maybe because getActionView()
is expecting SearchView but here a LinearLayout it being returned. I dont know how to work around this.