protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); if (Control != null) { Control.SetBackgroundColor(G.Color.Rgb(255, 255, 255)); } SearchView searchView = (Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); // Set custom colors textView.SetBackgroundColor(G.Color.Rgb(255, 255, 255)); textView.SetTextColor(G.Color.Rgb(0, 0, 0)); textView.SetHintTextColor(G.Color.Rgb(128, 128, 128)); // Customize frame color int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); frameView.SetBackgroundColor(G.Color.Rgb(255, 255, 255)); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args) { base.OnElementChanged(args); // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); if (Settings.TapjackProtectionSearch) { searchView.FilterTouchesWhenObscured = true; } // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); if (args.NewElement.FontFamily == null) { args.NewElement.FontFamily = CloudStreamForms.Settings.CurrentFont.FontStyle; } // Set custom colors // textView.SetBackgroundColor(G.Color.Rgb(25, 25, 25)); int color = Settings.BlackColor - 5; if (color < 0) { color = -color * 2; } textView.SetBackgroundColor(G.Color.Rgb(color, color, color));//Settings.BlackBg ? G.Color.Rgb(12, 12, 12) : G.Color.Rgb(25, 25, 25)); textView.SetHintTextColor(G.Color.Rgb(64, 64, 64)); textView.SetTextColor(G.Color.Rgb(200, 200, 200)); /* * textView.SetTextColor(G.Color.Rgb(32, 32, 32)); * textView.SetHintTextColor(G.Color.Rgb(128, 128, 128));*/ // Customize frame color int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); frameView.SetBackgroundColor(G.Color.Transparent);//G.Color.ParseColor(CloudStreamForms.Settings.MainBackgroundColor)); var searchIconId = searchView.Resources.GetIdentifier("android:id/search_mag_icon", null, null); if (searchIconId > 0) { var searchPlateIcon = searchView.FindViewById(searchIconId); searchPlateIcon.ScaleX = 0.75f; searchPlateIcon.ScaleY = 0.75f; searchPlateIcon.TranslationX = -5; (searchPlateIcon as ImageView).SetImageDrawable(context.GetDrawable(Resource.Drawable.MainSearchIcon)); (searchPlateIcon as ImageView).SetColorFilter(G.Color.Rgb(190, 190, 190)); } }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args) { base.OnElementChanged(args); // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); // Set custom colors // textView.SetBackgroundColor(G.Color.Rgb(25, 25, 25)); textView.SetBackgroundColor(Settings.BlackBg ? G.Color.Rgb(12, 12, 12) : G.Color.Rgb(25, 25, 25)); textView.SetHintTextColor(G.Color.Rgb(64, 64, 64)); textView.SetTextColor(G.Color.Rgb(200, 200, 200)); /* * textView.SetTextColor(G.Color.Rgb(32, 32, 32)); * textView.SetHintTextColor(G.Color.Rgb(128, 128, 128));*/ // Customize frame color int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); frameView.SetBackgroundColor(G.Color.ParseColor(CloudStreamForms.Settings.MainBackgroundColor)); //frameView.SetBackgroundColor(G.Color.Rgb(96, 96, 96)); /* * // Get native control (background set in shared code, but can use SetBackgroundColor here) * SearchView searchView = (base.Control as SearchView); * // searchView.SetBackgroundColor(new G.Color() { A = 1, R = 1, B = 255, G = 1 }); * searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); * * // Access search textview within control * int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); * EditText textView = (searchView.FindViewById(textViewId) as EditText); * * // Set custom colors * //textView.SetBackgroundColor(G.Color.Rgb(225, 225, 225)); * textView.SetHintTextColor(G.Color.Rgb(64, 64, 64)); * textView.SetTextColor(G.Color.Rgb(200, 200, 200)); * textView.SetBackgroundColor(new G.Color() { A = 1, R = 1, B = 255, G = 1 }); * * * // Customize frame color * int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); * Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); * Main.print(CloudStreamForms.Settings.MainBackgroundColor); * // frameView.SetBackgroundColor(G.Color.ParseColor(CloudStreamForms.Settings.MainBackgroundColor));*/ }
void showProgressBar(SearchView searchView, Context context) { int id = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); View searchPlate = searchView.FindViewById(id); if (searchView.FindViewById(id).FindViewById(Resource.Id.progressBar1) != null) { searchView.FindViewById(id).FindViewById(Resource.Id.progressBar1).Animate().SetDuration(200).Alpha(1).Start(); } else { View v = LayoutInflater.From(context).Inflate(Resource.Layout.loading, null); ((ViewGroup)searchView.FindViewById(id)).AddView(v, 1); } }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); //change icon search searchView.SetIconifiedByDefault(false); int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null); var icon = searchView.FindViewById(searchIconId); icon.SetBackgroundColor(Android.Graphics.Color.White); (icon as ImageView).SetImageResource(Resource.Drawable.ios23); //change icon close int searchViewCloseButtonId = Control.Resources.GetIdentifier("android:id/search_close_btn", null, null); var closeIcon = searchView.FindViewById(searchViewCloseButtonId); (closeIcon as ImageView).SetImageResource(Resource.Drawable.close); // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); textView.SetTextColor(Android.Graphics.Color.Black); textView.SetHintTextColor(Android.Graphics.Color.Rgb(180, 180, 180)); textView.TextAlignment = Android.Views.TextAlignment.TextStart; //add borders to the search bar if (textView != null) { var shape = new ShapeDrawable(new RectShape()); shape.Paint.Color = Android.Graphics.Color.Transparent; shape.Paint.StrokeWidth = 0; shape.Paint.SetStyle(Paint.Style.Stroke); textView.Background = shape; } var gradient = new GradientDrawable(); gradient.SetCornerRadius(5.0f); gradient.SetStroke((int)this.Context.ToPixels(1.0f), Android.Graphics.Color.Rgb(169, 169, 169)); this.Control.SetBackground(gradient); }
internal static void ShowKeyboard(this SearchView searchView) { if (searchView == null) { throw new ArgumentNullException(nameof(searchView)); } // Dig into the SearchView and find the actual TextView that we want to show keyboard input for int searchViewTextViewId = searchView.Resources.GetIdentifier("android:id/search_src_text", null, null); if (searchViewTextViewId == 0) { // Cannot find the resource Id; nothing else to do return; } var textView = searchView.FindViewById(searchViewTextViewId); if (textView == null) { // Cannot find the TextView; nothing else to do return; } using (var inputMethodManager = (InputMethodManager)searchView.Context.GetSystemService(Context.InputMethodService)) { // The zero value for the second parameter comes from // https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#showSoftInput(android.view.View,%20int) // Apparently there's no named value for zero in this case inputMethodManager?.ShowSoftInput(textView, 0); } }
private void SetBackground(SearchView control, Color color) { var searchPlateId = control.Context.Resources.GetIdentifier("android:id/search_plate", null, null); var searchPlate = control.FindViewById(searchPlateId); searchPlate.SetBackgroundColor(Color.Transparent); var gd = new GradientDrawable(); gd.SetColor(color); gd.SetCornerRadius(30); gd.SetStroke(2, Color.LightGray); //control.SetBackground(gd); var shadow = control.GenerateBackgroundWithShadow( Color.White, 60f, Color.LightGray, 10, GravityFlags.Center); control.SetClipToPadding(false); control.SetBackground(shadow); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); SearchView searchView = (base.Control as SearchView); int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); if (textView != null) { int searchMagIcon = searchView.Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null); ImageView magIcon = (ImageView)searchView.FindViewById(searchMagIcon); magIcon.SetColorFilter(global::Android.Graphics.Color.Rgb(255, 255, 255)); } }
private void setSearchIcons(SearchView mSearchView) { try { Java.Lang.Reflect.Field searchField = mSearchView.Class.GetDeclaredField("mSearchButton"); searchField.Accessible = true; ImageView searchBtn = (ImageView)searchField.Get(mSearchView); searchBtn.Background = null; searchBtn.SetImageResource(Resource.Drawable.search123); searchBtn.SetScaleType(ImageView.ScaleType.FitCenter); //searchBtn.LayoutParameters.Width = 80; //searchBtn.LayoutParameters.Height = 80; searchBtn.RequestLayout(); searchField = mSearchView.Class.GetDeclaredField("mSearchPlate"); searchField.Accessible = true; LinearLayout searchPlate = (LinearLayout)searchField.Get(mSearchView); ImageView closeBtn = ((ImageView)searchPlate.GetChildAt(1)); closeBtn.SetImageResource(Resource.Drawable.closed); closeBtn.SetScaleType(ImageView.ScaleType.FitCenter); //closeBtn.LayoutParameters.Width = 80; //closeBtn.LayoutParameters.Height = 80; closeBtn.RequestLayout(); //searchPlate.SetBackgroundResource(Resource.Drawable.SearchPlate); //searchPlate.LayoutParameters.Height = 1; int searchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); EditText plate = (EditText)mSearchView.FindViewById(searchPlateId); //plate.SetBackgroundColor(Color.White); plate.SetTextColor(Color.White); int voiceSearchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/submit_area", null, null); mSearchView.FindViewById(voiceSearchPlateId).SetBackgroundResource(Resource.Drawable.rounded_textview); // change hint color int searchTextViewId = mSearchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); TextView searchTextView = (TextView)mSearchView.FindViewById(searchTextViewId); searchTextView.SetHintTextColor(Resources.GetColor(Color.LightGray)); } catch (Exception ex) { //string dst = "sdfsfs"; //CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ? // bitopiApplication.User.UserName : ""); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.SearchDialog); Window.SetSoftInputMode(SoftInput.AdjustNothing); if (ActionBar != null) { this.Title = ActionBar.Title = GetString(Resource.String.search); ActionBar.SetDisplayUseLogoEnabled(false); ActionBar.SetIcon(new ColorDrawable(Color.Transparent)); ActionBar.SetHomeButtonEnabled(false); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetDisplayShowHomeEnabled(true); ActionBar.SetDisplayShowTitleEnabled(true); } _ListView = (ListView)FindViewById <ListView>(Resource.Id.pageList); _SearchView = (SearchView)FindViewById <SearchView>(Resource.Id.searchView); //_SearchView.Background = Resources.GetDrawable(Resource.Drawable.ic_action_refresh); int searchPlateId = _SearchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); View searchPlate = _SearchView.FindViewById(searchPlateId); searchPlate.Background.Colorize(DataManager.Get <ISettingsManager>().Settings.ButtonColor); _SearchView.Focusable = true; _SearchView.Iconified = false; _SearchView.RequestFocusFromTouch(); _SearchView.QueryTextChange += this.SearchBarTextChanged; /*(sender, e) => * { * SearchPerform(e.NewText); * };*/ _SearchView.QueryTextSubmit += (sender, e) => { _SearchView.ClearFocus(); }; _ListView.ItemClick += (sender, e) => { var item = _Pubblicazioni[e.Position]; Intent i = new Intent(); i.SetClass(Application.Context, typeof(ViewerScreen)); i.PutExtra("pubPath", item.Path); StartActivity(i); Finish(); }; }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); // Set custom colors //textView.SetBackgroundColor(Color.White.ToAndroid()); textView.SetTextColor(Xamarin.Forms.Color.White.ToAndroid()); textView.SetHintTextColor(Xamarin.Forms.Color.White.ToAndroid()); // Customize frame color int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); DroidView.View frameView = (searchView.FindViewById(frameId) as DroidView.View); //frameView.SetBackgroundColor(Color.White.ToAndroid()); var searchIconId = searchView.Resources.GetIdentifier("android:id/search_mag_icon", null, null); if (searchIconId > 0) { var searchPlateIcon = searchView.FindViewById(searchIconId); (searchPlateIcon as ImageView).SetColorFilter(Xamarin.Forms.Color.White.ToAndroid(), PorterDuff.Mode.SrcIn); } var searchCloseId = searchView.Resources.GetIdentifier("android:id/search_close_btn", null, null); if (searchCloseId > 0) { var searchCloseIcon = searchView.FindViewById(searchCloseId); (searchCloseIcon as ImageView).SetColorFilter(Xamarin.Forms.Color.White.ToAndroid(), PorterDuff.Mode.SrcIn); } }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); var searchBar = (CustomSearchBar)Element; // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); textView.SetHintTextColor(G.Color.Rgb(200, 200, 200)); textView.SetTextColor(global::Android.Graphics.Color.White); // Customize frame color int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); frameView.SetBackgroundColor(G.Color.Rgb(100, 100, 100)); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); SearchView searchView = Control; searchView.Iconified = true; searchView.SetIconifiedByDefault(false); int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null); var icon = searchView.FindViewById(searchIconId); icon.RemoveFromParent(); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); // Set custom colors textView.SetBackgroundColor(G.Color.Rgb(225, 225, 225)); textView.SetTextColor(G.Color.Rgb(74, 189, 172)); textView.SetHintTextColor(G.Color.Rgb(211, 211, 211)); // Customize frame color int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); //frameView.SetBackgroundColor(G.Color.Rgb(255, 255, 255)); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); // Set custom colors textView.SetTextColor(Color.Black); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args) { base.OnElementChanged(args); // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); searchView.Iconified = true; searchView.SetIconifiedByDefault(false); int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null); var icon = searchView.FindViewById(searchIconId); (icon as ImageView).SetImageResource(Resource.Drawable.ic_search_white_24dp); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); if (Control != null) { var plateId = Resources.GetIdentifier("android:id/search_plate", null, null); var plate = Control.FindViewById(plateId); plate.SetBackgroundColor(Android.Graphics.Color.Transparent); SearchView searchView = (base.Control as SearchView); var searchIconId = searchView.Resources.GetIdentifier("android:id/search_mag_icon", null, null); var searchIcon = searchView.FindViewById(searchIconId); (searchIcon as ImageView).SetColorFilter(Android.Graphics.Color.LightGray, PorterDuff.Mode.SrcIn); int editTextId = Resources.GetIdentifier("android:id/search_src_text", null, null); EditText editText = (Control.FindViewById(editTextId) as EditText); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.SearchDialog); Window.SetSoftInputMode(SoftInput.AdjustNothing); if (ActionBar != null) { this.Title = ActionBar.Title = GetString(Resource.String.search); ActionBar.SetDisplayUseLogoEnabled(false); ActionBar.SetIcon(new ColorDrawable(Color.Transparent)); ActionBar.SetHomeButtonEnabled(false); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetDisplayShowHomeEnabled(true); ActionBar.SetDisplayShowTitleEnabled(true); } _ListView = (ListView)FindViewById <ListView>(Resource.Id.pageList); _SearchView = (SearchView)FindViewById <SearchView>(Resource.Id.searchView); _Loader = (ProgressBar)FindViewById <ProgressBar>(Resource.Id.prgLoader); int searchPlateId = _SearchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); View searchPlate = _SearchView.FindViewById(searchPlateId); searchPlate.Background.Colorize(DataManager.Get <ISettingsManager>().Settings.ButtonColor); _SearchView.Focusable = true; _SearchView.Iconified = false; _SearchView.RequestFocusFromTouch(); _SearchView.QueryTextChange += this.SearchBarTextChanged; _SearchView.QueryTextSubmit += (sender, e) => { _SearchView.ClearFocus(); }; //_SearchView.HapticFeedbackEnabled = false; _SearchView.LongClickable = false; }
public override bool OnCreateOptionsMenu(IMenu menu) { MenuInflater.Inflate(Resource.Menu.options_menu, menu); var searchManager = (SearchManager)GetSystemService(Context.SearchService); searchView = (SearchView)menu.FindItem(Resource.Id.search).ActionView; //var searchItem = menu.FindItem (Resource.Id.search); int id = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); var searchText = (AutoCompleteTextView)searchView.FindViewById(id); searchText.SetTextColor(Resources.GetColor(Resource.Color.white)); searchText.SetHintTextColor(Resources.GetColor(Resource.Color.white)); searchView.SetSearchableInfo(searchManager.GetSearchableInfo(ComponentName)); searchView.Close += (sender, e) => { LoadingView.Visibility = ViewStates.Gone; FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, pubs).Commit(); }; return(true); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args) { base.OnElementChanged(args); // Get native control (background set in shared code, but can use SetBackgroundColor here) SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); // Set the magnifying classe's color to white. var searchIconId = searchView.Resources.GetIdentifier("android:id/search_mag_icon", null, null); var searchPlateIcon = searchView.FindViewById(searchIconId); (searchPlateIcon as ImageView).SetColorFilter(G.Color.White, G.PorterDuff.Mode.SrcIn); // Eliminate the grey underline bar for the search bar var plateId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); var plate = Control.FindViewById(plateId); plate.SetBackgroundColor(Android.Graphics.Color.Transparent); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Setting Searchview text colour SearchView sv = FindViewById <SearchView>(Resource.Id.sv); int id = sv.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); TextView tv = (TextView)sv.FindViewById(id); tv.SetTextColor(Android.Graphics.Color.Black); // To dismiss search programatically Button dismissSearch = FindViewById <Button>(Resource.Id.button1); dismissSearch.Click += delegate { sv.ClearFocus(); }; }
private void InitView() { //设置标题栏 var btn_header_back = FindViewById <Button> (Resource.Id.btn_header_back); btn_header_back.Click += (sender, e) => { this.Finish(); }; FindViewById <TextView> (Resource.Id.tv_header_title).Text = "监护人绑定"; listView = FindViewById <ListView> (Resource.Id.lv_searchGuardian); searchView = FindViewById <SearchView> (Resource.Id.searchView); searchView.SetOnQueryTextListener(this); //设置searchview中textview颜色 var id = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); textView = (TextView)searchView.FindViewById(id); textView.SetTextColor(Resources.GetColor(Resource.Color.lightgray)); //查询 var txt_Querry = FindViewById <TextView> (Resource.Id.txt_Querry); txt_Querry.Click += (sender, e) => { OnQueryTextSubmit(textView.Text); }; applyGuardianListAdapter = new ApplyGuardianListAdapter(this); applyGuardianListAdapter.RefreshAction = () => { QuerryBindGuardian(textView.Text); }; listView.Adapter = applyGuardianListAdapter; //设置滑动listview停止加载图片 listView.SetOnScrollListener(new PauseOnScrollListener(Global.imageLoader, false, false)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ZoekLand); //GET LOGIN STATUS bool LoginCheck = Intent.GetBooleanExtra("LoginCheck", false); int mUserID = Intent.GetIntExtra("mUserID", 0); string Username = Intent.GetStringExtra("Username"); _lv = FindViewById <ListView>(Resource.Id.lv); _sv = FindViewById <SearchView>(Resource.Id.sv); addData(); _adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, _al); _lv.Adapter = _adapter; _sv.QueryTextChange += _sv_QueryTextChange; _lv.ItemClick += (sender, e) => _lv_ItemClick(sender, e, LoginCheck, mUserID, Username); btnZoekBack = FindViewById <Button>(Resource.Id.btnZoekBack); btnZoekBack.Click += BtnZoekBack_Click; // SET TEXT COLOR & HINT TEXT COLOR SearchView sv = FindViewById <SearchView>(Resource.Id.sv); int id = sv.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); TextView tv = (TextView)sv.FindViewById(id); tv.SetTextColor(Android.Graphics.Color.ParseColor("#e77d4d")); sv.SetQueryHint("Typ hier om een land te zoeken."); sv.OnActionViewExpanded(); }
public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater) { base.OnCreateOptionsMenu(menu, inflater); inflater.Inflate(Resource.Menu.fragment_photo_gallery, menu); // Using SearchView if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { IMenuItem searchItem = menu.FindItem(Resource.Id.menu_item_search); SearchView searchView = (SearchView)searchItem.ActionView; // Get the data from our searchable.xml as a SearchableInfo SearchManager searchManager = (SearchManager)Activity.GetSystemService(Context.SearchService); ComponentName name = Activity.ComponentName; SearchableInfo searchInfo = searchManager.GetSearchableInfo(name); searchView.SetSearchableInfo(searchInfo); searchView.SubmitButtonEnabled = true; searchView.QueryTextFocusChange += (object sender, View.FocusChangeEventArgs e) => { if (e.HasFocus && lastQuery != null && lastQuery != String.Empty) { searchView.SetQuery(lastQuery, false); currentPage = 1; int id = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText editText = searchView.FindViewById <EditText>(id); editText.SelectAll(); } }; searchView.Close += async(object sender, SearchView.CloseEventArgs e) => { e.Handled = false; PreferenceManager.GetDefaultSharedPreferences(Activity).Edit().PutString(FlickrFetchr.PREF_SEARCH_QUERY, null).Commit(); query = null; currentPage = 1; await UpdateItems(); }; } }
void Background_PropertyChanged(object sender, PropertyChangingEventArgs eventArgs) { SearchView searchView = (base.Control as SearchView); searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); if (eventArgs.PropertyName == "IsdarkThemEnabled") { var isDarkTheme = false; //(App.Current as App).IsDarkThemeEnabled; //Can be set from the app from settings, but just set to false for now Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); if (isDarkTheme) { frameView.SetBackgroundColor(G.Color.Rgb(51, 48, 46)); } else { frameView.SetBackgroundColor(G.Color.Rgb(250, 250, 250)); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); _currentPage = Intent.GetIntExtra("currentPage", 0); _pubblicazione = (Pubblicazione)ActivitiesBringe.GetObject("pub"); _documento = (Documento)ActivitiesBringe.GetObject("doc"); _pdfCore = (MuPDFCore)ActivitiesBringe.GetObject("pdfCore"); SetContentView(Resource.Layout.SearchDialog); Window.SetSoftInputMode(SoftInput.AdjustNothing); if (ActionBar != null) { this.Title = ActionBar.Title = GetString(Resource.String.search); ActionBar.SetDisplayUseLogoEnabled(false); ActionBar.SetIcon(new ColorDrawable(Color.Transparent)); ActionBar.SetHomeButtonEnabled(false); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetDisplayShowHomeEnabled(true); ActionBar.SetDisplayShowTitleEnabled(true); } _pageList = (ListView)FindViewById <ListView>(Resource.Id.pageList); _searchView = (SearchView)FindViewById <SearchView>(Resource.Id.searchView); int searchPlateId = _searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); View searchPlate = _searchView.FindViewById(searchPlateId); searchPlate.Background.Colorize(DataManager.Get <ISettingsManager>().Settings.ButtonColor); _searchView.Focusable = true; _searchView.Iconified = false; _searchView.RequestFocusFromTouch(); _searchView.QueryTextChange += (sender, e) => { SearchPages(e.NewText); }; _searchView.QueryTextSubmit += (sender, e) => { _searchView.ClearFocus(); }; _pageList.ItemClick += (sender, e) => { var art = _articoli[e.Position]; Intent myIntent = new Intent(this, typeof(ViewerScreen)); myIntent.PutExtra("doc", art.IdDocumento); myIntent.PutExtra("page", (art.Index - 1).ToString()); myIntent.PutExtra("action", "page"); SetResult(Result.Ok, myIntent); Finish(); }; //paramentro ricerca var str = ActivitiesBringe.GetObject("search"); if (str != null) { string search = (string)str; _searchView.SetQuery(search, true); _searchView.RequestFocus(); } }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); searchView = Control; //linearLayout = Control; if (Control != null) { searchView.Iconified = false; searchView.SetIconifiedByDefault(false); searchView.BaselineAligned = false; searchView.BaselineAlignedChildIndex = 0; /* * linearLayout.RemoveAllViews(); * TextView label = new TextView(context); * label.Text = "hola"; * linearLayout.AddView(label); * Toolbar toolbar = new Toolbar(context); * toolbar.AddView(new RadioButton(context)); * linearLayout.AddView(toolbar); * */ //searchView.RemoveAllViews(); //FormsTextView label = new FormsTextView(context); //label.Text = "holaaa"; //searchView.AddView(label); // (Resource.Id.search_mag_icon); is wrong / Xammie bug //(icon as ImageView).SetImageResource(Resource.Drawable.search); //int cancelIconId = Context.Resources.GetIdentifier("android:id/search_close_btn", null, null); //var eicon = searchView.FindViewById(cancelIconId); //(eicon as ImageView).SetImageResource(Resource.Drawable.search); LinearLayout linearLayout = this.Control.GetChildAt(0) as LinearLayout; linearLayout = linearLayout.GetChildAt(2) as LinearLayout; linearLayout = linearLayout.GetChildAt(1) as LinearLayout; linearLayout.Background = null; //removes underline AutoCompleteTextView textView = linearLayout.GetChildAt(0) as AutoCompleteTextView; //modify for text appearance customization int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null); icon = searchView.FindViewById(searchIconId); icon.Visibility = ViewStates.Invisible; icon.RemoveFromParent(); var textView2Id = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); var textView2 = (searchView.FindViewById(textView2Id) as EditText); if (textView == null) { return; } textView.SetTextColor(global::Android.Graphics.Color.Black); IntPtr IntPtrtextViewClass = JNIEnv.FindClass(typeof(TextView)); IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I"); JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, Resource.Layout.design_layout_tab_text); // replace 0 with a Resource.Drawable.my_cursor Android.Widget.Button buttonFilter = new Android.Widget.Button(context); //buttonFilter.SetBackgroundResource(Resource.Drawable.ic_filter_list_black_24dp); //buttonFilter.SetBackgroundColor(Android.Graphics.Color.Transparent); //Toolbar toolbar = new Toolbar(context); toolbar = (toolbar.FindViewById(Resource.Layout.Toolbar) as Toolbar); //linearLayout.AddView(buttonFilter); <! IMPORTANTE !> //var editViewId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); //var editView = (searchView.FindViewById(editViewId) as ) //LinearLayout linearLayout = this.Control.GetChildAt(0) as LinearLayout; //linearLayout = linearLayout.GetChildAt(2) as LinearLayout; //linearLayout = linearLayout.GetChildAt(1) as LinearLayout; //AutoCompleteTextView textView = linearLayout.GetChildAt(0) as AutoCompleteTextView; //textView.SetTextColor(Android.Graphics.Color.Blue); } if (e.OldElement != null) { } if (e.NewElement != null) { } /* * if (e.NewElement == null) * { * * GradientDrawable gd = new GradientDrawable(); * gd.SetStroke(0, Android.Graphics.Color.Transparent); * * linearLayout.Background = gd; * * * textView.SetBackgroundColor(Android.Graphics.Color.Red); * * //ImageView icon = linearLayout.GetChildAt(1) as ImageView; * //icon.Visibility = ViewStates.Invisible; * * } */ }
private void HandleSuggestionClick(object sender, SearchView.SuggestionClickEventArgs e) { if (Element is ISearchPage searchPage) { SearchView searchView = (sender as SearchView); AppCompatAutoCompleteTextView autoComplete = (AppCompatAutoCompleteTextView)searchView.FindViewById(Resource.Id.search_src_text); var selectedItem = autoComplete.Adapter.GetItem(e.Position); searchPage.SearchTextEvent((string)selectedItem); } }