Hi All,
I have created a new simple Dot Net project with a separate UI and ViewModel project for Android. I have used a simple Xamarin.Android EditText control to rendered in Forms control. In some scenarios, I will handle the keyboard manually. So I have used the below codes to handle the keyboard. But the Context was not cast to Activity. The specified case was not found exception has occurred.
- Window window = ((Activity)this.Context).Window;
- InputMethodManager mgr = (InputMethodManager)((Activity)this.Context).GetSystemService(Context.InputMethodService);
- if (window != null)
- {
- window.SetSoftInputMode(SoftInput.StateHidden);
- mgr.HideSoftInputFromWindow(this.WindowToken, 0);
- }
I have attached the simple project to this post. Please help me to use the keypad manually.
Thanks in advance.
Answers
Know the answer? Post it. Somebody with the same question will find it here.