public override bool OnCreateOptionsMenu (IMenu menu) { //Used to put dark icons on light action bar bool isLight = SampleList.THEME == Resource.Style.Sherlock___Theme_Light; //Create the search view SearchView searchView = new SearchView (SupportActionBar.ThemedContext); searchView.QueryHint = "Search for countries…"; searchView.SetOnQueryTextListener (this); searchView.SetOnSuggestionListener (this); if (mSuggestionsAdapter == null) { MatrixCursor cursor = new MatrixCursor (COLUMNS); Converter<string, Java.Lang.Object> func = s => new Java.Lang.String (s); cursor.AddRow (Array.ConvertAll<string,Java.Lang.Object> (new string[] { "1", "'Murica" }, func)); cursor.AddRow (Array.ConvertAll<string,Java.Lang.Object> (new string[] { "2", "Canada" }, func)); cursor.AddRow (Array.ConvertAll<string,Java.Lang.Object> (new string[] { "3", "Denmark" }, func)); mSuggestionsAdapter = new SuggestionsAdapter (SupportActionBar.ThemedContext, cursor); } searchView.SuggestionsAdapter = mSuggestionsAdapter; menu.Add ("Search") .SetIcon (isLight ? Resource.Drawable.ic_search_inverse : Resource.Drawable.abs__ic_search) .SetActionView (searchView) .SetShowAsAction (MenuItem.ShowAsActionIfRoom | MenuItem.ShowAsActionCollapseActionView); return true; }
public override bool OnCreateOptionsMenu(IMenu menu) { //Used to put dark icons on light action bar bool isLight = SampleList.THEME == Resource.Style.Sherlock___Theme_Light; //Create the search view SearchView searchView = new SearchView(SupportActionBar.ThemedContext); searchView.QueryHint = "Search for countries…"; searchView.SetOnQueryTextListener(this); searchView.SetOnSuggestionListener(this); if (mSuggestionsAdapter == null) { MatrixCursor cursor = new MatrixCursor(COLUMNS); Converter <string, Java.Lang.Object> func = s => new Java.Lang.String(s); cursor.AddRow(Array.ConvertAll <string, Java.Lang.Object> (new string[] { "1", "'Murica" }, func)); cursor.AddRow(Array.ConvertAll <string, Java.Lang.Object> (new string[] { "2", "Canada" }, func)); cursor.AddRow(Array.ConvertAll <string, Java.Lang.Object> (new string[] { "3", "Denmark" }, func)); mSuggestionsAdapter = new SuggestionsAdapter(SupportActionBar.ThemedContext, cursor); } searchView.SuggestionsAdapter = mSuggestionsAdapter; menu.Add("Search") .SetIcon(isLight ? Resource.Drawable.ic_search_inverse : Resource.Drawable.abs__ic_search) .SetActionView(searchView) .SetShowAsAction(MenuItem.ShowAsActionIfRoom | MenuItem.ShowAsActionCollapseActionView); return(true); }