我的一个应用程序有一个“开机画面”(基本上是一个菜单),其中包括一个EditText
和几个Button
。问题是,我有几个用户报告说当他们打开应用程序时,屏幕上的键盘会自动弹出,而他们甚至没有触摸到EditText
。据我所知,所有这些用户都在使用HTC Hero。
这是 1.5 版本中的一个 bug 吗?我能做什么来解决它吗?
我的一个应用程序有一个“开机画面”(基本上是一个菜单),其中包括一个EditText
和几个Button
。问题是,我有几个用户报告说当他们打开应用程序时,屏幕上的键盘会自动弹出,而他们甚至没有触摸到EditText
。据我所知,所有这些用户都在使用HTC Hero。
这是 1.5 版本中的一个 bug 吗?我能做什么来解决它吗?
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "SectionMyFragment onResume");
hideKeyboard();
}
private void hideKeyboard() {
if (getActivity() != null) {
InputMethodManager inputMethodManager = (InputMethodManager)
getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
if (getActivity().getCurrentFocus() != null) {
Log.d(TAG, "hideSoftInputFromWindow 1");
inputMethodManager.hideSoftInputFromWindow((getActivity().getCurrentFocus()).getWindowToken(), 0);
}
}
}
}
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
imm.ShowSoftInput(_enterPin.FindFocus(), 0);
*这是针对Android.xamarin和FindFocus()的-它在以此视图为根的层次结构中搜索当前拥有焦点的视图,因为我在上述代码之前放置了_enterPin.RequestFocus(),因此它会为_enterPin EditText显示键盘*