Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 视图中的EditText未显示键盘_Android_Android Softkeyboard - Fatal编程技术网

Android 视图中的EditText未显示键盘

Android 视图中的EditText未显示键盘,android,android-softkeyboard,Android,Android Softkeyboard,我的应用程序已经开始表现出奇怪的行为,所以我认为一定有一个我没有把握的变化。我在RelativeLayout中有一个带有requestFocus属性的EditText。几个月来,我打开我的应用程序,执行一个初始化方法,然后触摸编辑文本,键盘就会出现。现在键盘没有出现。我尝试使用InputMethodManager设置onClick侦听器和onFocusChange,方法如下: m.showSoftInput(amountEditText, 0); 还有 m.toggleSoftInput(In

我的应用程序已经开始表现出奇怪的行为,所以我认为一定有一个我没有把握的变化。我在RelativeLayout中有一个带有requestFocus属性的EditText。几个月来,我打开我的应用程序,执行一个初始化方法,然后触摸编辑文本,键盘就会出现。现在键盘没有出现。我尝试使用InputMethodManager设置onClick侦听器和onFocusChange,方法如下:

m.showSoftInput(amountEditText, 0);
还有

m.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
由于这是一种新的、出乎意料的行为,我担心是我改变了什么导致了这种奇怪的行为。我已经查看了XML和WYSIWYG的视图,没有发现任何错误。所有答案似乎都有更复杂的情况,所以我认为一些更基本的错误。有人见过这个吗?

试试这个方法:

public static void showSoftkeyboard(android.view.View view, ResultReceiver resultReceiver) {
    Configuration config = view.getContext().getResources().getConfiguration();
    if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
        InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (resultReceiver != null) {
            imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT, resultReceiver);
        } else {
            imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
        }
    }
}

另外,如果您没有禁用活动的软键盘,请检查您的AndroidManifest.xml。

不久前,我遇到了类似的问题。强制显示键盘的一种方法是:

    //here my EditText is called editText_search
    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInputFromWindow(editText_search.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);

    editText_search.requestFocus();
另外,正如西蒙·马奎斯所指出的,看看你是否在清单中屏蔽或隐藏键盘


希望能有所帮助。

谢谢您的及时回复。我添加了这个方法,在onClick侦听器中没有ResultReceiver。我试过了。编辑文本接收焦点,并显示软键盘。我一点也不清楚为什么需要这样做,但我肯定会接受答案,thnx。
resultReceiver
是可选的