/// <summary> /// Clears the search view. /// </summary> private void clearSearchView() { searchView.SetQuery("", true); //set the query to empty InputMethodManager manager = (InputMethodManager)mActivity.GetSystemService(Context.InputMethodService); //get the keyboard manager manager.HideSoftInputFromWindow(searchView.WindowToken, 0); //hide the keyboard }
/// <summary> /// Закрыть клавиатуру /// </summary> /// <param name="activity"></param> /// <param name="view"></param> public static void HideKeyboard(FragmentActivity activity, View view) { if (activity != null && view != null) { var inputMethodManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService); inputMethodManager.HideSoftInputFromWindow(view.WindowToken, 0); } }
public void showKeyBoard(FragmentActivity activity) { InputMethodManager inputManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService); var currentFocus = activity.CurrentFocus; if (currentFocus != null) { inputManager.ShowSoftInput(currentFocus, ShowFlags.Forced); } }
public void hideKeyBoard(FragmentActivity activity) { InputMethodManager inputManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService); var currentFocus = activity.CurrentFocus; if (currentFocus != null) { inputManager.HideSoftInputFromWindow(currentFocus.WindowToken, HideSoftInputFlags.None); } }
public static void Construct(FragmentActivity activity, Toolbar toolbar) { MovieDbFactory.RegisterSettings(new MovieDbSettings()); _topRatedHelper = new MovieHelper(); _searchHelper = new MovieHelper(); _movieApi = MovieDbFactory.Create <IApiMovieRequest>().Value; _topRatedFragment = new TopRatedMoviesFragment(_topRatedHelper, _movieApi); var fragments = new Fragment[] { new MovieSearchFragment(_searchHelper, _movieApi), _topRatedFragment }; var titles = CharSequence.ArrayFromStringArray(new[] { activity.GetString(Resource.String.SearchTab), activity.GetString(Resource.String.TopRatedTab) }); var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager); viewPager.Adapter = new TabsFragmentPagerAdapter(activity.SupportFragmentManager, fragments, titles); // Give the TabLayout the ViewPager var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs); tabLayout.SetupWithViewPager(viewPager); tabLayout.TabSelected += async(sender, args) => { var tab = args.Tab; if (tab.Position == 1) { viewPager.SetCurrentItem(tab.Position, true); var manager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService); manager.HideSoftInputFromWindow(activity.CurrentFocus.WindowToken, 0); await _topRatedFragment.GetMovies(); } else { viewPager.SetCurrentItem(tab.Position, true); } }; SetToolbar(activity, toolbar); }
public static void Construct(FragmentActivity activity, Toolbar toolbar) { var _otherFragment = new OtherFragment(); var fragments = new Fragment[] { new MovieInputFragment(), _otherFragment }; var titles = CharSequence.ArrayFromStringArray(new[] { "Movies", "Top Rated" }); var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager); viewPager.Adapter = new TabsFragmentPagerAdapter(activity.SupportFragmentManager, fragments, titles); // Give the TabLayout the ViewPager var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs); tabLayout.SetupWithViewPager(viewPager); tabLayout.TabSelected += async(sender, args) => { viewPager.Enabled = false; var tab = args.Tab; if (tab.Position == 1) { var manager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService); manager.HideSoftInputFromWindow(tabLayout.WindowToken, 0); _otherFragment.enableSpinner(); await _otherFragment.FetchTopRatedMovies(); } viewPager.Enabled = true; }; SetToolbar(activity, toolbar); }
public static void HideKeyboard(FragmentActivity activity, View view) { InputMethodManager imm = (InputMethodManager)activity.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(view.WindowToken, 0); }
public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { var view = convertView; if (view == null) { var inflater = activity.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; view = inflater.Inflate(Resource.Layout.StocksViewListItem, null); } var item = items[groupPosition]; view.FindViewById <TextView>(Resource.Id.Name).Text = item.Name; view.FindViewById <TextView>(Resource.Id.Exchange).Text = item.Exchange; view.FindViewById <TextView>(Resource.Id.Ticker).Text = item.Ticker; view.FindViewById <TextView>(Resource.Id.Qty).Text = item.Qty; view.FindViewById <TextView>(Resource.Id.IsShort).Text = item.IsShort; view.FindViewById <TextView>(Resource.Id.OriginalPrice).Text = item.OriginalPrice; view.FindViewById <TextView>(Resource.Id.OriginalDate).Text = item.OriginalDate; view.FindViewById <TextView>(Resource.Id.CurrentPrice).Text = item.CurrentPrice; view.FindViewById <TextView>(Resource.Id.CurrentDate).Text = item.CurrentDate; view.FindViewById <TextView>(Resource.Id.ChangeFromLastTrade).Text = item.ChangeFromLastTrade; view.FindViewById <TextView>(Resource.Id.ChangePctFromLastTrade).Text = item.ChangePctFromLastTrade; view.FindViewById <TextView>(Resource.Id.TotalCost).Text = item.TotalCost; view.FindViewById <TextView>(Resource.Id.TotalCurrentCost).Text = item.TotalCurrentCost; view.FindViewById <TextView>(Resource.Id.TotalChange).Text = item.TotalChange; view.FindViewById <TextView>(Resource.Id.TotalChangePct).Text = item.TotalChangePct; if (!view.FindViewById <Button>(Resource.Id.btnRemove).HasOnClickListeners) { view.FindViewById <Button>(Resource.Id.btnRemove).Click += (o, e) => { DBLayer.Delete(new Stock() { ID = item.Id }); this.activity.Recreate(); }; } var ctx = this.activity.ApplicationContext; if (!view.FindViewById <Button>(Resource.Id.btnEdit).HasOnClickListeners) { view.FindViewById <Button>(Resource.Id.btnEdit).Click += (o, e) => { var intent = new Intent(ctx, typeof(HomeAdd)).SetFlags(ActivityFlags.NewTask); intent.PutExtra("Id", item.Id.ToString()); ctx.StartActivity(intent); }; } //if (!IsFixed) // return view; var chgLastTrade = view.FindViewById <TextView>(Resource.Id.ChangeFromLastTrade); var chgPctLastTrade = view.FindViewById <TextView>(Resource.Id.ChangePctFromLastTrade); var totalChange = view.FindViewById <TextView>(Resource.Id.TotalChange); var totalChangePct = view.FindViewById <TextView>(Resource.Id.TotalChangePct); var name = view.FindViewById <TextView>(Resource.Id.Name); var ex = view.FindViewById <TextView>(Resource.Id.Exchange); var t = view.FindViewById <TextView>(Resource.Id.Ticker); var qty = view.FindViewById <TextView>(Resource.Id.Qty); var isShort = view.FindViewById <TextView>(Resource.Id.IsShort); var origPrice = view.FindViewById <TextView>(Resource.Id.OriginalPrice); var origDt = view.FindViewById <TextView>(Resource.Id.OriginalDate); var curPrice = view.FindViewById <TextView>(Resource.Id.CurrentPrice); var curDt = view.FindViewById <TextView>(Resource.Id.CurrentDate); var totalCost = view.FindViewById <TextView>(Resource.Id.TotalCost); var totalCurCost = view.FindViewById <TextView>(Resource.Id.TotalCurrentCost); FixColor(chgLastTrade); FixColor(chgPctLastTrade); FixColor(totalChange); FixColor(totalChangePct); MakeYellow(ex, chgLastTrade); MakeYellow(t, chgLastTrade); MakeYellow(qty, chgLastTrade); MakeYellow(isShort, chgLastTrade); MakeYellow(origPrice, chgLastTrade); MakeYellow(origDt, chgLastTrade); MakeYellow(curPrice, chgLastTrade); MakeYellow(curDt, chgLastTrade); MakeYellow(totalCost, chgLastTrade); MakeYellow(totalCurCost, chgLastTrade); name.SetTextColor(Color.Chocolate); return(view); }