这是我显示键盘的代码:
AppData.SoftKeyBoard += () =>
{
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
imm.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
};
我需要一种方法来隐藏软键盘。
答案 0 :(得分:1)
此代码用于隐藏Xamarin Native Android片段中的软键盘:
View view = inflater.Inflate(Resource.Layout.fragment, container, false);
var imm =(InputMethodManager)Activity.GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(view.WindowToken, 0);
,在“活动”中,您可以使用以下代码:
InputMethodManager imm = (InputMethodManager)this.GetSystemService(Activity.InputMethodService);
//Find the currently focused view, so we can grab the correct window token from it.
View view = this.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(this);
}
imm.HideSoftInputFromWindow(view.WindowToken, 0);
答案 1 :(得分:0)
你走了。这是Visual Studio的代码。
// Hide keyboard
var inputManager = (InputMethodManager)GetSystemService(InputMethodService);
inputManager.HideSoftInputFromWindow(btnSignIn.WindowToken, HideSoftInputFlags.None);