public override bool OnTouchEvent(MotionEvent e) { InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, 0); View current = this.CurrentFocus; if (current != null) { current.ClearFocus(); } return(base.OnTouchEvent(e)); }
// // Hide Keyboard from the view public static void HideKeyboard(Activity activity, String methodService) { try { if (activity != null) { InputMethodManager manager = (InputMethodManager)activity.GetSystemService(methodService); manager.HideSoftInputFromWindow(activity.CurrentFocus.WindowToken, 0); } } catch (Exception e) { } }
public void HideKeyboard() { try { if (Control != null) { Control.RequestFocus(); InputMethodManager inputMethodManager = Control.Context.GetSystemService(Context.InputMethodService) as InputMethodManager; inputMethodManager.HideSoftInputFromWindow(this.Control.WindowToken, HideSoftInputFlags.None); } } catch (Exception) { } }
public static void HideSoftKeyboard(this Activity activity) { if (activity.CurrentFocus == null) { return; } InputMethodManager inputMethodManager = (InputMethodManager)activity.GetSystemService(Android.Content.Context.InputMethodService); inputMethodManager.HideSoftInputFromWindow(activity.CurrentFocus.WindowToken, 0); activity.CurrentFocus.ClearFocus(); }
void HideKeyboard() { InputMethodManager inputMethodManager = (InputMethodManager)GetSystemService(InputMethodService); try { inputMethodManager.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } }
public override void BecomeFirstResponder( ) { InputMethodManager imm = ( InputMethodManager )Rock.Mobile.PlatformSpecific.Android.Core.Context.GetSystemService(Android.Content.Context.InputMethodService); //Activity activity = ( Activity )Rock.Mobile.PlatformSpecific.Android.Core.Context; //imm.HideSoftInputFromWindow( activity.CurrentFocus.WindowToken, 0 ); TextView.FocusableInTouchMode = true; TextView.RequestFocus( ); imm.ShowSoftInput(TextView, ShowFlags.Implicit); //imm.ShowSoftInputFromInputMethod( TextView.WindowToken, 0 ); }
private void Drawer_DrawerOpened(object sender, DrawerLayout.DrawerOpenedEventArgs e) { if (CurrentFocus == null) { return; } InputMethodManager inputMethodManager = (InputMethodManager)this.GetSystemService(Android.Content.Context.InputMethodService); inputMethodManager.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0); CurrentFocus.ClearFocus(); }
public bool IsKeyboardVisible(View widget) { InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); bool keyboardMaybePresent = imm.IsActive || imm.IsAcceptingText; if (keyboardMaybePresent) // if it's true doesn't mean much... { keyboardMaybePresent = !m_keyboardVisible; } m_keyboardVisible = keyboardMaybePresent; return(m_keyboardVisible); }
protected void Resume() { base.OnResume(); InputMethodManager manager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); manager.HideSoftInputFromWindow(_view.WindowToken, 0); Task.Run(async() => { await ViewModel.FetchWorkOrders(); ViewModel.SwitchBack(); }); }
protected void DismissKeyboard(View focusedView) { try { InputMethodManager imm = (InputMethodManager)this.RequireContext() .GetSystemService(Android.Content.Context.InputMethodService); imm.HideSoftInputFromWindow(focusedView.WindowToken, 0); } catch (Exception) { Log.Debug(this.GetType().Name, "Error closing the keyboard"); } }
/// <summary> /// Hide key board when refresh layout. /// </summary> /// <param name="activity"></param> public static void HideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager)activity.GetSystemService(Activity.InputMethodService); //Find the currently focused view, so we can grab the correct window token from it. View view = activity.CurrentFocus; //If no view currently has focus, create a new one, just so we can grab a window token from it if (view == null) { view = new View(activity); } imm.HideSoftInputFromWindow(view.WindowToken, 0); }
private void TxtJamaTarikh_Click(object sender, EventArgs e) { InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways); DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime time) { txtJamaTarikh.Text = time.ToString("dd-MM-yyyy"); }); frag.Show(FragmentManager, DatePickerFragment.TAG); }
public KeyboardService() { Device.StartTimer(TimeSpan.FromMilliseconds(25), () => { im = Android.App.Application.Context.GetSystemService(Context.InputMethodService) as InputMethodManager; if (im.IsAcceptingText != _lastAcceptingText) { Forms9Patch.KeyboardService.OnVisiblityChange(im.IsAcceptingText ? KeyboardVisibilityChange.Shown : KeyboardVisibilityChange.Hidden); _lastAcceptingText = im.IsAcceptingText; } return(true); }); }
void keyboardState(string _state, EditText _edittext) { InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); if (_state == "HIDDEN") { imm.HideSoftInputFromWindow(_edittext.WindowToken, 0); } else { imm.ShowSoftInput(_edittext, 0); } }
protected void HideKeyboard(string view) { try { InputMethodManager inputMethodManager = (InputMethodManager)this .GetSystemService(Activity.InputMethodService); inputMethodManager.HideSoftInputFromWindow(Window.CurrentFocus.WindowToken, 0); } catch (Exception e) { Log.Debug(view, e.Message); } }
private void _editor_KeyPress(object sender, View.KeyEventArgs e) { if (e.KeyCode == Keycode.Enter) { InputMethodManager mgr = (InputMethodManager)GetSystemService(InputMethodService); mgr.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, 0); _editor.Visibility = ViewStates.Invisible; } else { e.Handled = false; } }
private void Anim_AnimationEndUp(object sender, Android.Views.Animations.Animation.AnimationEndEventArgs e) { mIsAnimating = false; if (mSearch.HasFocus == true) { InputMethodManager inputManager = (InputMethodManager)mContext.GetSystemService(Context.InputMethodService); inputManager.ToggleSoftInput(0, 0); mSearch.ClearFocus(); } }
public void HideSoftKeyboard() { if (CurrentFocus == null) { return; } InputMethodManager inputMethodManager = (InputMethodManager)GetSystemService(InputMethodService); inputMethodManager.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0); CurrentFocus.ClearFocus(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LoginRootView = this.BindingInflate(Resource.Layout.LoginView, null); SetContentView(LoginRootView); LoginRootView.ViewTreeObserver.AddOnGlobalLayoutListener(this); ((LoginViewModel)base.ViewModel).PropertyChanged += (sender, e) => { if (e.PropertyName == LoginViewModel.IsLoadingPropertyName) { if (LoginViewModel.IsLoading) { InputMethodManager manager = (InputMethodManager)GetSystemService(InputMethodService); manager.HideSoftInputFromWindow(LoginRootView.WindowToken, 0); } } }; LoginViewModel.ErrorHandler += (sender, e) => { ErrorEventArgs ee = (ErrorEventArgs)e; var dispatcher = Mvx.Resolve <IMvxMainThreadDispatcher> (); dispatcher.RequestMainThreadAction(() => { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(ee.Title); builder.SetMessage(ee.Message); builder.SetNegativeButton(ee.CloseTitle, (EventHandler <DialogClickEventArgs>)null); builder.Show(); }); }; LoginViewModel.UpdateClientHandler += (sender, e) => { var ee = (UpdateClientEventArgs)e; var dispatcher = Mvx.Resolve <IMvxMainThreadDispatcher> (); dispatcher.RequestMainThreadAction(() => { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(ee.Title); builder.SetMessage(ee.Message); builder.SetNegativeButton(ee.CloseTitle, new EventHandler <DialogClickEventArgs>( (s, args) => { LoginViewModel.showUpdateStore(); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); })); builder.Show(); }); }; ((LoginViewModel)base.ViewModel).IsLoading = false; RootView.FromLogin = true; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.StudentProfileRecView, container, false); stopwatch = new Stopwatch(); stopwatch.Start(); progressBar = view.FindViewById <ProgressBar>(Resource.Id.circularProgress); candidateName = view.FindViewById <TextView>(Resource.Id.candidateName); candidateEmail = view.FindViewById <TextView>(Resource.Id.candidateEmail); candidateSchool = view.FindViewById <TextView>(Resource.Id.schoolText); candidateMajor = view.FindViewById <TextView>(Resource.Id.majorText); candidateGT = view.FindViewById <TextView>(Resource.Id.gradtermText); candidateGPA = view.FindViewById <TextView>(Resource.Id.gpaText); notes = view.FindViewById <EditText>(Resource.Id.notes); Button nextButton = view.FindViewById <Button>(Resource.Id.nextButton); star = view.FindViewById <ImageView>(Resource.Id.star); heart = view.FindViewById <ImageView>(Resource.Id.heart); ImageView backButton = view.FindViewById <ImageView>(Resource.Id.backButton); Button hideKeyboard = view.FindViewById <Button>(Resource.Id.hideKeyboard); LinearLayout rootLayout = view.FindViewById <LinearLayout>(Resource.Id.rootLayout); LoadCandidateInfo(); hideKeyboard.Visibility = ViewStates.Invisible; hideKeyboard.Click += (sender, e) => { InputMethodManager imm = (InputMethodManager)this.Activity.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(notes.WindowToken, 0); rootLayout.RequestFocus(); hideKeyboard.Visibility = ViewStates.Invisible; }; notes.FocusChange += (sender, e) => { hideKeyboard.Visibility = ViewStates.Visible; }; backButton.Click += (sender, e) => { Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, new QsFragment()); trans.Commit(); }; nextButton.Click += NextButton_Click; star.Click += Star_Click; heart.Click += Heart_Click; return(view); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { try { base.OnViewCreated(view, savedInstanceState); MAddTextEditText = view.FindViewById <EditText>(Resource.Id.add_text_edit_text); MAddTextDoneTextView = view.FindViewById <TextView>(Resource.Id.add_text_done_tv); //Setup the color picker for text color AddTextColorPickerRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.add_text_color_picker_recycler_view); FontTypeFaceRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.fontTypeFace_recycler_view); LayoutManager = new LinearLayoutManager(view.Context, LinearLayoutManager.Horizontal, false); AddTextColorPickerRecyclerView.SetLayoutManager(LayoutManager); AddTextColorPickerRecyclerView.HasFixedSize = true; LayoutManagerTypeFace = new LinearLayoutManager(view.Context, LinearLayoutManager.Horizontal, false); FontTypeFaceRecyclerView.SetLayoutManager(LayoutManagerTypeFace); FontTypeFaceRecyclerView.HasFixedSize = true; ColorPickerAdapter = new ColorPickerAdapter(Activity, ColorType.ColorNormal); ColorPickerAdapter.ItemClick += ColorPickerAdapterOnItemClick; AddTextColorPickerRecyclerView.SetAdapter(ColorPickerAdapter); TypeFaceAdapter = new FontTypeFaceAdapter(Activity); TypeFaceAdapter.ItemClick += TypeFaceAdapterOnItemClick; FontTypeFaceRecyclerView.SetAdapter(TypeFaceAdapter); MAddTextEditText.Text = Arguments.GetString(ExtraInputText); var dd = Arguments.GetInt(ExtraColorCode); MColorCode = Arguments.GetString(ExtraColorCode) ?? "#ffffff"; MAddTextEditText.SetTextColor(Color.ParseColor(MColorCode)); MInputMethodManager = (InputMethodManager)view.Context.GetSystemService(Context.InputMethodService); MInputMethodManager.ToggleSoftInput(ShowFlags.Forced, 0); FontTxt6 = Typeface.CreateFromAsset(view.Context.Assets, "SF-UI-Display-Regular.ttf"); MAddTextDoneTextView.Click += MAddTextDoneTextViewOnClick; MAddTextDoneTextView.SetTypeface(FontTxt6, TypefaceStyle.Normal); } catch (Exception e) { Console.WriteLine(e); } }
private void CheckKeyboardNeed() { InputMethodManager inputMethodManager = Application.Context.GetSystemService(Context.InputMethodService) as InputMethodManager; if (InputHandler.KeyboardFocus != null && InputHandler.KeyboardFocus.KeyboardNeeded && InputHandler.KeyboardFocus.IsVisible && !inputMethodManager.IsAcceptingText) { inputMethodManager.ShowSoftInput(this, ShowFlags.Forced); inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly); } else if (inputMethodManager.IsActive) { inputMethodManager.HideSoftInputFromWindow(WindowToken, HideSoftInputFlags.None); } }
public void ShowKeyboard() { try { if (Control != null) { Control.RequestFocus(); InputMethodManager inputMethodManager = Control.Context.GetSystemService(Context.InputMethodService) as InputMethodManager; inputMethodManager.ShowSoftInput(Control, ShowFlags.Forced); inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly); } } catch (Exception) { } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.SessionView); _textToSend = FindViewById <EditText> (Resource.Id.textViewUpload); _tvShareCount = FindViewById <TextView> (Resource.Id.tvShareCount); _tvCodeWord = FindViewById <TextView> (Resource.Id.tvCodeWord); _tvHistoryLabel = FindViewById <TextView> (Resource.Id.tvHistoryLabel); _chooseContent = FindViewById <Button> (Resource.Id.btnChooseContent); _mainLayout = FindViewById <LinearLayout> (Resource.Id.shareLayout); var btnSend = FindViewById <Button> (Resource.Id.buttonSend); btnSend.Click += (object sender, EventArgs e) => { SendText(); }; _textToSend.KeyPress += (object sender, View.KeyEventArgs e) => { if (e.KeyCode == Keycode.Enter && e.Event.Action == KeyEventActions.Down) { SendText(); } else { e.Handled = false; } }; _chooseContent.Click += ChooseFile; var phrase = Intent.GetStringExtra("Secret"); _secret = CrossCopyApp.HistoryData.Secrets.Where(s => s.Phrase == phrase).SingleOrDefault(); if (_secret == null) { Finish(); } _secret.WatchEvent += UpdateSharedDevicesCount; CrossCopyApp.Srv.CurrentSecret = _secret; GetString(Resource.String.SessionTitle); _tvCodeWord.Text = _secret.Phrase; _tvShareCount.Text = GetString(Resource.String.ShareWithNoDevices); _inflater = (LayoutInflater)GetSystemService(Context.LayoutInflaterService); _inputMethodManager = (InputMethodManager)GetSystemService(InputMethodService); HandlePossibleSharedContent(); }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Android.Resource.Id.Home: drawerLayout.OpenDrawer(Android.Support.V4.View.GravityCompat.Start); InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways); return(true); } return(base.OnOptionsItemSelected(item)); }
private void hideInput() { if (manager == null) { manager = (InputMethodManager)GetSystemService(Context.InputMethodService); } if (manager.IsActive && CurrentFocus != null) { if (CurrentFocus.WindowToken != null) { manager.HideSoftInputFromWindow(CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways); } } }
public AndroidInputMethod(TView host) { if (host.OnCheckIsTextEditor() == false) { throw new InvalidOperationException("Host should return true from OnCheckIsTextEditor()"); } _host = host; _imm = host.Context.GetSystemService(Context.InputMethodService).JavaCast <InputMethodManager>(); _host.Focusable = true; _host.FocusableInTouchMode = true; _host.ViewTreeObserver.AddOnGlobalLayoutListener(new SoftKeyboardListener(_host)); }
private void Main_LoginPage_Click(object sender, EventArgs e) { if (Chk_agree.Checked) { InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService); inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.None); } else { IMethods.DialogPopup.InvokeAndShowDialog(this, this.GetText(Resource.String.Lbl_Warning), this.GetText(Resource.String.Lbl_Error_Terms), this.GetText(Resource.String.Lbl_Ok)); } }
public static void LostFocusFromField(int fieldId) { View lastField = Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity.FindViewById(fieldId); lastField.FocusChange += (object sender, View.FocusChangeEventArgs e) => { if (!lastField.HasFocus) { InputMethodManager inputManager = (InputMethodManager)Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity.GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(lastField.WindowToken, 0); } }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //Set our view from the "main" layout resource RequestWindowFeature(Android.Views.WindowFeatures.NoTitle); SetContentView(Resource.Layout.SignInView); emailField = FindViewById <EditText>(Resource.Id.emailField); password = FindViewById <EditText>(Resource.Id.passwordField); forgotPWButton = FindViewById <Button>(Resource.Id.forgotPasswordButton); signInButton = FindViewById <ImageButton>(Resource.Id.signInButton); facebookButton = FindViewById <ImageButton>(Resource.Id.facebookButton); signUpButton = FindViewById <ImageButton>(Resource.Id.signUpButton); //MapActivity mapActivity = new MapActivity().OnCreate(bundle); //InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); signUpButton.Click += (object sender, EventArgs args) => { //Pull up dialog FragmentTransaction transaction = FragmentManager.BeginTransaction(); DialogSignUp dialogSignUp = new DialogSignUp(); dialogSignUp.Show(transaction, "dialog fragment"); dialogSignUp.OnSignUpComplete += SignUpDialog_mOnSignUpComplete; }; signInButton.Click += (object sender, EventArgs args) => { //Get entered field values signInEmail = emailField.Text; signInPassword = password.Text; if (true) { //Dismiss Keybaord InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(signInButton.WindowToken, 0); var list = new Intent(this, typeof(ListViewActivity)); StartActivity(list); } else { //Dismiss Keybaord InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); //imm.HideSoftInputFromWindow(signInButton.WindowToken, 0); Toast.MakeText(ApplicationContext, "Invalid login", ToastLength.Long).Show(); } }; }