private void InitToolbar(View view) { try { var toolbar = view.FindViewById <Toolbar>(Resource.Id.toolbar); if (toolbar != null) { GlobalContext.SetToolBar(toolbar, ""); SearchBox = view.FindViewById <SearchView>(Resource.Id.searchBox); SearchBox.SetIconifiedByDefault(false); SearchBox.OnActionViewExpanded(); SearchBox.Iconified = false; SearchBox.QueryTextSubmit += SearchViewOnQueryTextSubmit; SearchBox.QueryTextChange += SearchViewOnQueryTextChange; SearchBox.ClearFocus(); //Change text colors var editText = (EditText)SearchBox.FindViewById(Resource.Id.search_src_text); editText.SetHintTextColor(Color.White); editText.SetTextColor(Color.White); //Remove Icon Search ImageView searchViewIcon = (ImageView)SearchBox.FindViewById(Resource.Id.search_mag_icon); ViewGroup linearLayoutSearchView = (ViewGroup)searchViewIcon.Parent; linearLayoutSearchView.RemoveView(searchViewIcon); } } catch (Exception e) { Console.WriteLine(e); } }
private async void InitComponent() { try { MapIcon = FindViewById <TextView>(Resource.Id.map_icon); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, MapIcon, IonIconsFonts.AndroidLocate); ListIcon = FindViewById <TextView>(Resource.Id.list_icon); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ListIcon, IonIconsFonts.AndroidList); MapButton = FindViewById <LinearLayout>(Resource.Id.map_button); ListButton = FindViewById <LinearLayout>(Resource.Id.list_button); SearchView = FindViewById <SearchView>(Resource.Id.searchView); SearchView.SetQuery("", false); SearchView.SetIconifiedByDefault(false); SearchView.OnActionViewExpanded(); SearchView.Iconified = false; SearchView.ClearFocus(); //Change text colors var editText = (EditText)SearchView.FindViewById(Resource.Id.search_src_text); editText.SetHintTextColor(Color.White); editText.SetTextColor(Color.White); editText.Hint = GetText(Resource.String.Lbl_SearchForPlace); //Change Color Icon Search ImageView searchViewIcon = (ImageView)SearchView.FindViewById(Resource.Id.search_mag_icon); searchViewIcon.SetColorFilter(Color.White); BtnSelect = FindViewById <FloatingActionButton>(Resource.Id.add_button); MAdapter = new PlacesAdapter(this); MAdapter.ItemClick += MAdapterOnItemClick; var mapFrag = SupportMapFragment.NewInstance(); SupportFragmentManager.BeginTransaction().Add(Resource.Id.map, mapFrag, mapFrag.Tag).Commit(); mapFrag.GetMapAsync(this); if (!string.IsNullOrEmpty(UserDetails.Lat) || !string.IsNullOrEmpty(UserDetails.Lng)) { Lat = Convert.ToDouble(UserDetails.Lat); Lng = Convert.ToDouble(UserDetails.Lng); OnLocationChanged(); } else { await GetPosition(); } } catch (Exception e) { Console.WriteLine(e); } }
private void InitToolbar() { try { var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); if (toolbar != null) { toolbar.Title = " "; toolbar.SetTitleTextColor(Color.White); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); } SearchBox = FindViewById <SearchView>(Resource.Id.searchBox); SearchBox.SetQuery("", false); SearchBox.SetIconifiedByDefault(false); SearchBox.OnActionViewExpanded(); SearchBox.Iconified = false; SearchBox.QueryTextChange += SearchViewOnQueryTextChange; SearchBox.QueryTextSubmit += SearchViewOnQueryTextSubmit; SearchBox.ClearFocus(); //Change text colors var editText = (EditText)SearchBox.FindViewById(Resource.Id.search_src_text); editText.SetHintTextColor(Color.White); editText.SetTextColor(Color.White); //Remove Icon Search ImageView searchViewIcon = (ImageView)SearchBox.FindViewById(Resource.Id.search_mag_icon); ViewGroup linearLayoutSearchView = (ViewGroup)searchViewIcon.Parent; linearLayoutSearchView.RemoveView(searchViewIcon); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void InitializeSearchView() { _searchView = new SearchView(_localContext); _toolBar.InflateMenu(Resource.Layout.mainmenu); _searchView = _toolBar.Menu?.FindItem(Resource.Id.action_search)?.ActionView?.JavaCast <SearchView>(); _searchView.QueryTextChange += searchView_QueryTextChange; _searchView.QueryTextSubmit += searchView_QueryTextSubmit; //_searchView.QueryHint = (Element as CustomSearchPage)?.Text; _searchView.ImeOptions = (int)ImeAction.Search; _searchView.InputType = (int)InputTypes.TextVariationNormal; _searchView.MaxWidth = int.MaxValue; _searchView.QueryHint = "Search..."; _searchView.Focusable = true; _searchView.Clickable = true; _searchView.SetOnSearchClickListener(new OnSearchClickListener(this)); int closeButtonId = Resource.Id.search_close_btn; ImageView closeButtonImage = (ImageView)_searchView.FindViewById(closeButtonId); closeButtonImage.SetImageResource(Resource.Drawable.ic_clear_black_24dp); var searchViewLinearLayout = (LinearLayout)_searchView.GetChildAt(0); var sViewUnderLayout = (Android.Widget.LinearLayout)searchViewLinearLayout.GetChildAt(2); var vsearch1_3_1 = (Android.Support.V7.Widget.AppCompatImageView)sViewUnderLayout.GetChildAt(0); var textViewLayout = (Android.Widget.LinearLayout)sViewUnderLayout.GetChildAt(1); var vsearch1_3_3 = (Android.Widget.LinearLayout)sViewUnderLayout.GetChildAt(2); var textView = (Android.Support.V7.Widget.AppCompatAutoCompleteTextView)textViewLayout.GetChildAt(0); textView.SetTextColor(Android.Graphics.Color.Rgb(80, 80, 80)); textView.SetHintTextColor(Android.Graphics.Color.Rgb(90, 90, 90)); textView.FocusSearch(FocusSearchDirection.Left); textView.Click += TextView_Click; var search = ((actionMenuView?.FindViewById <Android.Support.V7.View.Menu.ActionMenuItemView>(Resource.Id.action_search))?.ItemData as Android.Support.V7.View.Menu.MenuItemImpl)?.SetActionView(_searchView); }
public override bool OnCreateOptionsMenu(IMenu menu) { MenuInflater.Inflate(Resource.Menu.SearchGif_Menu, menu); var item = menu.FindItem(Resource.Id.searchUserBar); SearchView searchItem = (SearchView)item.ActionView; SearchView = searchItem.JavaCast <SearchView>(); SearchView.SetIconifiedByDefault(true); SearchView.QueryTextChange += SearchView_OnTextChange; SearchView.QueryTextSubmit += SearchView_OnTextSubmit; //Change text colors var editText = (EditText)SearchView.FindViewById(Resource.Id.search_src_text); editText.SetHintTextColor(Color.Gray); editText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); return(base.OnCreateOptionsMenu(menu)); }
private void OnNewToolbarRequest(ToolbarRequestMessage request) { switch (request) { case ToolbarRequestMessage.ShowSaveButton: Toolbar.Menu.Add(0, (int)ToolbarActionMessage.ClickedSaveButton, 0, "Save") .SetIcon(Resource.Drawable.icon_save) .SetShowAsAction(ShowAsAction.Always); break; case ToolbarRequestMessage.ResetToolbar: Toolbar.Menu.Clear(); break; case ToolbarRequestMessage.ShowSearchInterface: Toolbar.Post(() => { _searchView = new SearchView(this) { LayoutParameters = new Toolbar.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) }; _searchView.MaxWidth = int.MaxValue; _searchView.FindViewById <TextView>(Resource.Id.search_src_text).SetOnEditorActionListener( new OnEditorActionListener( tuple => { Messenger.Default.Send(new SearchQueryMessage(_searchView.Query)); })); Toolbar.Menu.Add(0, -1, 0, "Search") .SetActionView(_searchView) .SetIcon(Resource.Drawable.icon_search) .SetOnActionExpandListener(this) .SetShowAsActionFlags(ShowAsAction.CollapseActionView | ShowAsAction.IfRoom); }); break; default: throw new ArgumentOutOfRangeException(nameof(request), request, null); } }
public override bool OnCreateOptionsMenu(IMenu menu) { try { MenuInflater.Inflate(Resource.Menu.Search_menue, menu); var item = menu.FindItem(Resource.Id.searchUserBar); var searchItem = MenuItemCompat.GetActionView(item); _SearchView = searchItem.JavaCast <SearchView>(); _SearchView.SetIconifiedByDefault(false); _SearchView.SetQuery("", false); _SearchView.ClearFocus(); _SearchView.OnActionViewExpanded(); _SearchView.Iconified = false; _SearchView.SetIconifiedByDefault(false); _SearchView.OnActionViewExpanded(); //Remove Icon Search ImageView searchViewIcon = (ImageView)_SearchView.FindViewById(Resource.Id.search_mag_icon); ViewGroup linearLayoutSearchView = (ViewGroup)searchViewIcon.Parent; linearLayoutSearchView.RemoveView(searchViewIcon); _SearchView.QueryTextChange += _SearchView_OnTextChange; _SearchView.QueryTextSubmit += _SearchView_OnTextSubmit; InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService); inputManager.HideSoftInputFromWindow(_SearchView.WindowToken, 0); return(base.OnCreateOptionsMenu(menu)); } catch (Exception e) { Console.WriteLine(e); return(false); } }
//https://philio.me/styling-the-searchview-with-appcompat-v21/ //https://code.google.com/p/android/issues/detail?id=70754 public void Init(string searchIdName, string textFieldHint, bool topLine, bool serachLine, bool bottomline = false) { _stoppingPlaceViewModel = Stops.Setup.IoC.Container.Get <Core.ViewModels.SearchViewModel> (); /* * Load last selected on startup */ _searchView = _view.FindViewById <Android.Support.V7.Widget.SearchView> (Resource.Id.SearchFragmentSearch); _searchView.QueryHint = textFieldHint; _searchView.SetOnQueryTextListener(this); _searchView.SetOnSuggestionListener(this); ((EditText)_searchView.FindViewById(Resource.Id.search_src_text)).CustomSelectionActionModeCallback = this; if (mSuggestionsAdapter == null) { MatrixCursor cursor = new MatrixCursor(COLUMNS); mSuggestionsAdapter = new SuggestionsAdapter(Android.App.Application.Context, cursor); } _searchView.SuggestionsAdapter = mSuggestionsAdapter; if (!topLine) { var topLineView = _view.FindViewById <FrameLayout> (Resource.Id.SearchFragmentTopLine); topLineView.Visibility = topLine ? ViewStates.Visible : ViewStates.Gone; } if (!serachLine) { var view = _view.FindViewById <FrameLayout> (Resource.Id.SearchFragmentDragLine); view.Visibility = serachLine ? ViewStates.Visible : ViewStates.Gone; } if (!bottomline) { var view = _view.FindViewById <FrameLayout>(Resource.Id.SearchFragmentBottomLine); view.Visibility = serachLine ? ViewStates.Visible : ViewStates.Gone; } int searchEditTextId = Resource.Id.search_src_text; // for AppCompat // get AutoCompleteTextView from SearchView AutoCompleteTextView searchEditText = (AutoCompleteTextView)_searchView.FindViewById(searchEditTextId); View dropDownAnchor = _searchView.FindViewById(searchEditText.DropDownAnchor); dropDownAnchor.AddOnLayoutChangeListener(this); searchEditText.LongClick += (object sender, View.LongClickEventArgs e) => { SetChoicedStop(null); }; /* * Init the view model and set the last chocied stop */ _stoppingPlaceViewModel.Init(searchIdName); if (_stoppingPlaceViewModel.HasLatestCLickeStop()) { _choicedStop = _stoppingPlaceViewModel.GetLatestCLickeStop(); _ignoreAutoCompleteTextChange = true; _searchView.SetQuery(_choicedStop.Name, true); Events.Trigger("initWithStop", _choicedStop, 100); } var btnPos = _view.FindViewById <ImageButton> (Resource.Id.btnPos); btnPos.Click += (object sender, EventArgs e) => { Events.Trigger("locationClick", null); return; }; }