安卓屏幕键盘自动弹出问题

144

我的一个应用程序有一个“开机画面”(基本上是一个菜单),其中包括一个EditText和几个Button。问题是,我有几个用户报告说当他们打开应用程序时,屏幕上的键盘会自动弹出,而他们甚至没有触摸到EditText。据我所知,所有这些用户都在使用HTC Hero

这是 1.5 版本中的一个 bug 吗?我能做什么来解决它吗?


1
如果是一个错误,那么很可能是在Sprint Hero上特别存在的。Sprint在销售的Heros上有一个有缺陷的Android版本,他们似乎并没有急于推出针对它的错误修复。Sprint Heros和所有其他Android设备之间的行为差异非常多。据我所知,欧洲等其他版本的Hero没有这些问题。 - Mark B
不幸的是,欧洲的英雄机存在重大问题,这些问题会因版本号的更改而变化,但我们已经遇到了3-4个重大错误。 - Donal Rafferty
12个回答

0
如果您正在使用片段,则需要在onResume和onCreate中每次调用hideKeyboard,以便隐藏键盘。
    @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);
            }
        }
    }
}

0
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
        imm.ShowSoftInput(_enterPin.FindFocus(), 0);

*这是针对Android.xamarin和FindFocus()的-它在以此视图为根的层次结构中搜索当前拥有焦点的视图,因为我在上述代码之前放置了_enterPin.RequestFocus(),因此它会为_enterPin EditText显示键盘*


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接