为什么当我在ViewPager中点击editText时,softKeyboard为什么没有打开? [英] Why doesn't the softKeyboard open when I tap an editText inside a ViewPager?

查看:71
本文介绍了为什么当我在ViewPager中点击editText时,softKeyboard为什么没有打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像标题中所说的,我有一个viewPager,里面有一些editText字段.我可以很好地选择editText字段(仿真器和物理设备).我看到了光标,并且看到了下划线颜色的变化,表明它已被选中,但是我无法键入.点击editText字段不会打开softKeyboard.

Like the title says, I've got a viewPager with some editText fields inside. I can select the editText fields perfectly fine (emulator and physical device). I see the cursor, and I see the underline color change, indicating it's selected, but I can't type. Tapping on the editText fields doesn't open the softKeyboard.

这是一个已知问题,并且具有简单的修复程序,还是需要代码来确定这里出了什么问题?

Is this a known issue with a simple fix, or is code needed to identify what's going wrong here?

推荐答案

最后碰到一个对我有用的答案,可以在

Finally bumped in to an answer that's working for me, which can be found here.

基本上,如果使用的是onCreateDialog()方法,则将其保留不变,然后将下面的onResume()方法添加到DialogFragment的Java文件中.

Basically, if you're using the onCreateDialog() method, you leave that as is, and add the onResume() method below to your DialogFragment's java file.

@Override
public void onResume() {
    super.onResume();
    Dialog dialog = getDialog();
    dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}

这篇关于为什么当我在ViewPager中点击editText时,softKeyboard为什么没有打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆