我使用xamarin + mvvmcross创建Android应用程序。我在MvxFragment中有一个MvxAutoCompleteTextView。在MvxAutoCompleteTextView中输入内容并单击其他控件后,我想隐藏虚拟键盘。我使用以下代码:
public class MyFragment : MvxFragment
{
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView(inflater, container, savedInstanceState);
var view = this.BindingInflate(Resource.Layout.frMy, null);
var autoComplete = view.FindViewById<MvxAutoCompleteTextView>(Resource.Id.acMy);
InputMethodManager inputManager = (InputMethodManager)inflater.Context.GetSystemService(Context.InputMethodService);
inputManager.HideSoftInputFromWindow(autoComplete.WindowToken, HideSoftInputFlags.None);
return view;
}
}
但这并不起作用。我该如何隐藏键盘?