void FnClickEvents() { toolbar.MenuItemClick += Toolbar_MenuItemClick; //Listening to child item selection lvCartItemList.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e) { searchViewSearchItems.ClearFocus(); Toast.MakeText((MainActivity)this.Activity, "child clicked", ToastLength.Short).Show(); }; //Listening to group expand //modified so that on selection of one group other opened group has been closed lvCartItemList.GroupExpand += delegate(object sender, ExpandableListView.GroupExpandEventArgs e) { searchViewSearchItems.ClearFocus(); if (e.GroupPosition != previousGroup) { //lvCartItemList.CollapseGroup(previousGroup); //previousGroup = e.GroupPosition; } }; //Listening to group collapse lvCartItemList.GroupCollapse += delegate(object sender, ExpandableListView.GroupCollapseEventArgs e) { searchViewSearchItems.ClearFocus(); Toast.MakeText((MainActivity)this.Activity, "group collapsed", ToastLength.Short).Show(); }; }
private void SearchView_OnTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { try { SearchText = e.NewText; SearchView.ClearFocus(); SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; MAdapter.MentionList.Clear(); MAdapter.NotifyDataSetChanged(); StartSearchRequest(); //Hide keyboard programmatically in MonoDroid e.Handled = true; SearchView.ClearFocus(); var inputManager = (InputMethodManager)GetSystemService(InputMethodService); inputManager.HideSoftInputFromWindow(ToolBar.WindowToken, 0); } catch (Exception exception) { Console.WriteLine(exception); } }
private void SearchView_OnTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { try { SearchText = e.NewText; SearchView.ClearFocus(); MAdapter.JobList.Clear(); MAdapter.NotifyDataSetChanged(); StartApiService(); //Hide keyboard programmatically in MonoDroid e.Handled = true; SearchView.ClearFocus(); var inputManager = (InputMethodManager)GetSystemService(InputMethodService); inputManager.HideSoftInputFromWindow(ToolBar.WindowToken, 0); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
public void OnClick(View v) { if (v.Id != SearchBox.Id) { return; } SearchFragment searchFragment = new SearchFragment(); GlobalContext.FragmentBottomNavigator.DisplayFragment(searchFragment); SearchBox.ClearFocus(); }
public override bool OnCreateOptionsMenu(IMenu menu) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater.Inflate(Resource.Menu.menu_file_list, menu); var item = menu.FindItem(Resource.Id.action_search); var searchView = MenuItemCompat.GetActionView(item); mSearchView = searchView.JavaCast <Android.Support.V7.Widget.SearchView>(); mSearchView.MaxWidth = int.MaxValue; mSearchView.QueryHint = Resources.GetText(Resource.String.search_songs); mSearchView.SetOnQueryTextListener(this); MenuItemCompat.SetOnActionExpandListener(item, new FileListSearchViewExpandListener(this)); if (searchOpen) { MenuItemCompat.ExpandActionView(item); if (!TextUtils.IsEmpty(queryToSave)) { mSearchView.SetQuery(queryToSave, false); } mSearchView.ClearFocus(); } return(true); }
private void _searchView_QueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { try { SearchKey = e.NewText; MRecycler.Visibility = ViewStates.Visible; MAdapter.VideoList.Clear(); SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; StartApiService(); //Hide keyboard programmatically in MonoDroid e.Handled = true; SearchView.ClearFocus(); var inputManager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(ToolBar.WindowToken, 0); } catch (Exception exception) { Console.WriteLine(exception); } }
private void SearchViewOnQueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { try { SearchKey = e.NewText; if (SearchKey.Length >= 4) { CatRecycler.Visibility = ViewStates.Gone; MRecycler.Visibility = ViewStates.Visible; MAdapter.VideoList.Clear(); SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; StartApiService(); e.Handled = true; SearchBox.ClearFocus(); } else { Toast.MakeText(Activity, GetText(Resource.String.Lbl_The_search_term), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }
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 void SearchView_QueryTextChange(object sender, QueryTextChangeEventArgs e) { if (e.NewText.Length > 0) { RunOnUiThread(() => { if (viewPager.CurrentItem != 2) { viewPager.SetCurrentItem(2, true); } stopsFragment.OnQueryTextChanged(sender, e); }); } if (lastSearch.Length > 1 && e.NewText.Length == 0) { RunOnUiThread(() => { searchView.ClearFocus(); searchView.Iconified = true; stopsFragment.OnQueryTextChanged(sender, e); }); searchView.PostDelayed(() => { InputMethodManager inputMethodManager = GetSystemService(Context.InputMethodService) as InputMethodManager; inputMethodManager.HideSoftInputFromWindow(searchView.WindowToken, HideSoftInputFlags.None); }, 250); } lastSearch = e.NewText; }
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); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FnSetUpMainView(inflater, container); FnSetUpData(); FnSetUpControls(); FnSetUpEvents(); FnSetCustomersList(); searchViewSearchCustomers.OnActionViewExpanded(); //show edit mode of searchview searchViewSearchCustomers.ClearFocus(); //clear focus and hide keyboard return(mThisFragmentView); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.products_fragment_items_size_select); FnSetUpToolBar(); FnSetControls(); FnSetEvents(); FnGetData(); FnSetListViewAdapter(""); //SearchBar searchBar.OnActionViewExpanded(); //show edit mode of searchview searchBar.ClearFocus(); //clear focus and hide keyboard }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.checkout_select_customer); FnGetData(); FnSetUpControls(); FnSetUpToolbar(); FnSetUpEvents(); if (mIsCustomer) { FnPopulateCustomers(""); } else { FnPopulateRunners(""); } //SearchBar searchBar.OnActionViewExpanded(); //show edit mode of searchview searchBar.ClearFocus(); //clear focus and hide keyboard }
private void FnSetUpControls() { searchViewSearchTransactions = mThisFragmentView.FindViewById <SearchView>(Resource.Id.searchBar); mRecyclerViewTransactionList = mThisFragmentView.FindViewById <RecyclerView>(Resource.Id.recyclerViewTransactions); mRlDateFilter = mThisFragmentView.FindViewById <RelativeLayout>(Resource.Id.rlDateFilter); mTxtDateFilterText = mThisFragmentView.FindViewById <TextView>(Resource.Id.txtDateFilterText); mTxtSaleAmountAndCount = mThisFragmentView.FindViewById <TextView>(Resource.Id.txtSaleAmountAndCount); mImgRemoveFilter = mThisFragmentView.FindViewById <ImageView>(Resource.Id.imgRemoveFilter); searchViewSearchTransactions.OnActionViewExpanded(); //show edit mode of searchview searchViewSearchTransactions.ClearFocus(); //clear focus and hide keyboard searchViewSearchTransactions.QueryHint = "Search customer, transaction #"; searchViewSearchTransactions.SetOnQueryTextFocusChangeListener(new SearchViewFocusListener(Context, "TransactionsFragment")); }
private void SearchView_QueryTextSubmitAsync(object sender, Android.Support.V7.Widget.SearchView.QueryTextSubmitEventArgs e) { _searchView.ClearFocus(); _searchView.OnActionViewCollapsed(); SearchOffset = string.Empty; Adapter.Clear(); CurrentMode = APIMode.Search; onScrollListener.IsLoading = true; HideShowProgress(); searchQuery = e.Query; SupportActionBar.Title = e.Query; SeachProducts(searchQuery, SearchOffset); }
public void RefreshPricingType(bool _clearCart) { //clear on cart items if pricing type is changed if (_clearCart) { GlobalVariables.globalProductsOnCart.Clear(); SetCheckoutButtonTotal(mBtnCheckoutButton, Context);//refresh total button } //refresh list string queryString = ""; searchViewSearchItems.SetQuery("", false); searchViewSearchItems.ClearFocus(); mRecyclerViewItemsList.SetAdapter(new CheckoutRecyclerViewAdapter(mDpVal, SetItemListContainerHeight(mGridHolder, toolbar), PopulateProductData2(queryString), PopulateParentProducts(queryString), mIsGrid, mRecyclerViewItemsList, mBtnCheckoutButton, Context, mShowSizes, this, GlobalVariables.mCurrentSelectedPricingType)); mRecyclerViewItemsList.Invalidate(); }
public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater) { Activity.MenuInflater.Inflate(Resource.Menu.Search_Menu, menu); var item = menu.FindItem(Resource.Id.searchUserBar); SearchView searchItem = (SearchView)item.ActionView; SearchView = searchItem.JavaCast <SearchView>(); SearchView.SetQuery("", false); SearchView.ClearFocus(); SearchView.OnActionViewCollapsed(); SearchView.SetIconifiedByDefault(true); SearchView.OnActionViewExpanded(); SearchView.QueryTextChange += _searchView_QueryTextChange; SearchView.QueryTextSubmit += _searchView_QueryTextSubmit; base.OnCreateOptionsMenu(menu, inflater); }
public override bool OnCreateOptionsMenu(IMenu menu) { MenuInflater.Inflate(Resource.Menu.Search_Menu, menu); var item = menu.FindItem(Resource.Id.searchUserBar); var searchItem = MenuItemCompat.GetActionView(item); _SearchView = searchItem.JavaCast <SearchView>(); _SearchView.SetQuery("", false); _SearchView.ClearFocus(); _SearchView.OnActionViewExpanded(); _SearchView.SetIconifiedByDefault(true); _SearchView.OnActionViewExpanded(); _SearchView.QueryTextChange += SearchViewOnQueryTextChange; _SearchView.QueryTextSubmit += SearchViewOnQueryTextSubmit; return(base.OnCreateOptionsMenu(menu)); }
private void _SearchView_OnTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { try { search_key = e.Query; Get_GifData_Api(search_key); //Hide keyboard programmatically in MonoDroid e.Handled = true; _SearchView.ClearFocus(); var inputManager = (InputMethodManager)GetSystemService(InputMethodService); inputManager.HideSoftInputFromWindow(ToolBar.WindowToken, 0); } catch (Exception exception) { Console.WriteLine(exception); } }
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 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); } }
private void SearchView_OnTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { try { SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; SearchKey = e.NewText; MAdapter.GifList.Clear(); MAdapter.NotifyDataSetChanged(); if (!Methods.CheckConnectivity()) { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } else { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => LoadGif() }); } //Hide keyboard programmatically in MonoDroid e.Handled = true; SearchView.ClearFocus(); var inputManager = (InputMethodManager)GetSystemService(InputMethodService); inputManager.HideSoftInputFromWindow(ToolBar.WindowToken, 0); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private void SearchView_QueryTextSubmitAsync(object sender, Android.Support.V7.Widget.SearchView.QueryTextSubmitEventArgs e) { txtSearch.Visibility = ViewStates.Gone; imgSearch.Visibility = ViewStates.Gone; _searchView.ClearFocus(); _searchView.OnActionViewCollapsed(); e.Handled = true; searchQuery = e.Query; SearchOffset = string.Empty; maxIndex = 0; if (Adapter != null && Adapter.Product.Count > 0) { Adapter.Clear(); } if (SubCategory != null && SubCategory.Count > 0) { search?.Invoke(this, null); } else { GetSubCategories(); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.searchResult); var app = ((InitApp)ApplicationContext); if (app != null) { app.addActivity(this); } tv_question = FindViewById <TextView>(Resource.Id.tv_question); tv_news = FindViewById <TextView>(Resource.Id.tv_news); tv_kb = FindViewById <TextView>(Resource.Id.tv_kb); tv_blog = FindViewById <TextView>(Resource.Id.tv_blog); search_keyword = FindViewById <SearchView>(Resource.Id.search_keyword); _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorScheme(Resource.Color.primary); swipeRefreshLayout.Refreshing = false; StatusBarUtil.SetColorStatusBars(this); category = Intent.GetStringExtra("category"); keyword = Intent.GetStringExtra("keyword"); startQuery = Intent.GetBooleanExtra("startquery", false); initCategoryClick(); //初始化category单击事件 initCategoryByCategory(); //初始化category 选中的状态 toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); toolbar.NavigationClick += (s, e) => { ActivityCompat.FinishAfterTransition(this); }; swipeRefreshLayout.Refresh += (s, e) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); }; _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this)); //search_keyword.SubmitButtonEnabled = true; //默认为false 不显示提交按钮,是否启用提交按钮 search_keyword.OnActionViewExpanded(); //手动展开SearchView输入框,初始可以点击输入的状态 //search_keyword.SetIconifiedByDefault(false); //默认是为true 不显示输入框键盘,默认提交按钮不显示,该属性设置为false,则直接展开输入框弹出键盘 // search_keyword.RequestFocus(); //将控件设置成可获取焦点状态,默认是无法获取焦点的,只有设置成true,才能获取控件的点击事件 //search_keyword.Focusable = true; search_keyword.ClearFocus(); search_keyword.Focusable = true; if (!string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = keyword; } search_keyword.FocusChange += (s, e) => { System.Diagnostics.Debug.Write(e.HasFocus); if (e.HasFocus) { SearchInputActivity.Enter(category, this); } }; search_keyword.SetOnQueryTextFocusChangeListener(this); search_keyword.QueryTextSubmit += async(s, e) => { keyword = search_keyword.Query.Trim(); if (keyword == null || keyword.Length == 0) { return; } SearchHistoryShared.SetSearchHistory(keyword, this); swipeRefreshLayout.Refreshing = true; await listSearchService((list) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); searchList = list; initRecycler(); }); }; if (startQuery) { initCategoryByCategory(); SearchHistoryShared.SetSearchHistory(keyword, this); if (!string.IsNullOrEmpty(keyword)) { swipeRefreshLayout.Refreshing = true; await listSearchService((list) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); searchList = list; initRecycler(); }); } } }
protected override void OnCreate(Bundle savedInstanceState) { try { this.Window.SetSoftInputMode(SoftInput.AdjustNothing); base.OnCreate(savedInstanceState); IMethods.IApp.FullScreenApp(this); // Set our view from the "OnlineSearch_Layout" layout resource SetContentView(Resource.Layout.OnlineSearch_Layout); var ToolBar = FindViewById <Toolbar>(Resource.Id.mainSearchtoolbar); SetSupportActionBar(ToolBar); SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.SetDisplayShowTitleEnabled(false); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); //Get values SearchRecyler = FindViewById <RecyclerView>(Resource.Id.searchRecylerview); Btn_SearchRandom = FindViewById <Button>(Resource.Id.SearchRandom_Button); OnlineSearch_Empty = FindViewById <LinearLayout>(Resource.Id.OnlineSearch_LinerEmpty); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); swipeRefreshLayout.Enabled = false; FloatingActionButtonView = FindViewById <FloatingActionButton>(Resource.Id.floatingActionButtonView); //Set Adapter mLayoutManager = new LinearLayoutManager(this); SearchRecyler.SetLayoutManager(mLayoutManager); mAdapter = new SearchUser_Adapter(this); mAdapter.mSearchUserList = new ObservableCollection <GetSearchObject.User>(); SearchRecyler.SetAdapter(mAdapter); var data = Intent.GetStringExtra("Key") ?? "Data not available"; if (data != "Data not available" && !String.IsNullOrEmpty(data)) { if (search_key == "Random") { search_key = "a"; GetSearch_Result("a"); } else { search_key = data; if (_SearchView != null) { _SearchView.SetQuery(search_key, false); _SearchView.ClearFocus(); _SearchView.OnActionViewCollapsed(); } GetSearch_Result(search_key); } } //Close keybourd InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService); if (inputManager.IsActive) { if (ToolBar != null) { inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService); inputManager.HideSoftInputFromWindow(ToolBar.WindowToken, 0); } } _SearchView.ClearFocus(); AdsGoogle.Ad_Interstitial(this); } catch (Exception e) { Console.WriteLine(e); } }
private async void SearchViewOnQueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { try { SearchText = e.NewText; if (string.IsNullOrEmpty(SearchText) || string.IsNullOrWhiteSpace(SearchText)) { return; } SearchView.ClearFocus(); //Show a progress RunOnUiThread(() => { AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading)); }); var latLng = await GetLocationFromAddress(SearchText.Replace(" ", "")); if (latLng != null) { RunOnUiThread(() => { AndHUD.Shared.Dismiss(this); }); DeviceAddress = SearchText; Lat = latLng.Latitude; Lng = latLng.Longitude; // Creating a marker MarkerOptions markerOptions = new MarkerOptions(); // Setting the position for the marker markerOptions.SetPosition(latLng); var addresses = await ReverseGeocodeCurrentLocation(latLng); if (addresses != null) { DeviceAddress = addresses.GetAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex() //string city = addresses.Locality; //string state = addresses.AdminArea; //string country = addresses.CountryName; //string postalCode = addresses.PostalCode; //string knownName = addresses.FeatureName; // Only if available else return NULL // Setting the title for the marker. // This will be displayed on taping the marker markerOptions.SetTitle(DeviceAddress); } // Clears the previously touched position Map.Clear(); // Animating to the touched position Map.AnimateCamera(CameraUpdateFactory.NewLatLng(latLng)); // Placing a marker on the touched position Map.AddMarker(markerOptions); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(latLng); builder.Zoom(18); builder.Bearing(155); builder.Tilt(65); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); Map.MoveCamera(cameraUpdate); } else { RunOnUiThread(() => { AndHUD.Shared.Dismiss(this); }); //Error Message Toast.MakeText(this, GetText(Resource.String.Lbl_Error_DisplayAddress), ToastLength.Short).Show(); } } catch (Exception exception) { RunOnUiThread(() => { AndHUD.Shared.Dismiss(this); }); Console.WriteLine(exception); } }