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); } }
protected override void OnResume() { try { base.OnResume(); if (_SearchView != null) { _SearchView.SetQuery("", false); _SearchView.ClearFocus(); _SearchView.SetIconifiedByDefault(false); _SearchView.OnActionViewExpanded(); } //Event mAdapter.ItemClick += MAdapterOnItemClick; mAdapter.ItemLongClick += MAdapterOnItemLongClick; Btn_SearchRandom.Click += BtnSearchRandomOnClick; FloatingActionButtonView.Click += Filter_OnClick; swipeRefreshLayout.Refresh += SwipeRefreshLayoutOnRefresh; } catch (Exception e) { Console.WriteLine(e); } }
private void btnSearchActivate_Click(object sender, EventArgs e) { toolbar.RemoveView(inactiveSearchView); toolbar.AddView(activeSearchView); searchViewSearchItems.OnActionViewExpanded(); mToolbarVisibiltyStatus = false; //remove menu items and replace with activated searchbar toolbar.Menu.SetGroupVisible(Resource.Id.menugroup_search, mToolbarVisibiltyStatus); }
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); }
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)); }
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 }
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 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")); }
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); }
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) { MenuInflater.Inflate(Resource.Menu.menu_shopping, menu); var item = menu.FindItem(Resource.Id.search); var item2 = menu.FindItem(Resource.Id.action_cart); var searchView = MenuItemCompat.GetActionView(item); _searchView = searchView.JavaCast <Android.Support.V7.Widget.SearchView>(); var hint = Resources.GetString(Resource.String.hint_search_in); _searchView.QueryHint = Resources.GetString(Resource.String.hint_search); _searchView.QueryTextSubmit += SearchView_QueryTextSubmitAsync; _searchView.OnActionViewExpanded(); View actionView = MenuItemCompat.GetActionView(item2); _CartItemCount = actionView.FindViewById <ImageView>(Resource.Id.cart_badge); mCartItemCount = app.GetInt("MyCart", 0); if (mCartItemCount == 0) { _CartItemCount.Visibility = ViewStates.Gone; } else { _CartItemCount.Visibility = ViewStates.Visible; } actionView.Click += (o, e) => { ActivityOptionsCompat option = ActivityOptionsCompat.MakeSceneTransitionAnimation(this); Intent i = new Intent(this, typeof(MyCart_Activity)); StartActivity(i, option.ToBundle()); }; return(base.OnCreateOptionsMenu(menu)); }
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 }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.searchInput); var app = ((InitApp)ApplicationContext); if (app != null) { app.addActivity(this); } StatusBarUtil.SetColorStatusBars(this); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); toolbar.NavigationClick += (s, e) => { //ActivityCompat.FinishAfterTransition(this); ActivityCompat.FinishAfterTransition(this); this.Finish(); }; initSearchHistory(); category = Intent.GetStringExtra("category"); keyword = Intent.GetStringExtra("keyword"); search_keyword = FindViewById <SearchView>(Resource.Id.search_keyword); search_keyword.QueryTextSubmit += (h, _keyword) => { keyword = _keyword.Query.Trim(); if (keyword == null || keyword.Length == 0) { return; } SearchResultActivity.Enter(category, keyword, true, this); }; //search_keyword.SetIconifiedByDefault(false); //设置展开图标的样式 search_keyword.OnActionViewExpanded(); //初始可以点击输入的状态 search_keyword.RequestFocus(); //将控件设置成可获取焦点状态,默认是无法获取焦点的,只有设置成true,才能获取控件的点击事件 search_keyword.Focusable = true; }
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(); }); } } }
private void SearchBar_Click(object sender, EventArgs e, SearchView s) { s.OnActionViewExpanded(); }