1. <i id='tZPcR'><tr id='tZPcR'><dt id='tZPcR'><q id='tZPcR'><span id='tZPcR'><b id='tZPcR'><form id='tZPcR'><ins id='tZPcR'></ins><ul id='tZPcR'></ul><sub id='tZPcR'></sub></form><legend id='tZPcR'></legend><bdo id='tZPcR'><pre id='tZPcR'><center id='tZPcR'></center></pre></bdo></b><th id='tZPcR'></th></span></q></dt></tr></i><div id='tZPcR'><tfoot id='tZPcR'></tfoot><dl id='tZPcR'><fieldset id='tZPcR'></fieldset></dl></div>
    1. <tfoot id='tZPcR'></tfoot>

      <small id='tZPcR'></small><noframes id='tZPcR'>

        <bdo id='tZPcR'></bdo><ul id='tZPcR'></ul>
    2. <legend id='tZPcR'><style id='tZPcR'><dir id='tZPcR'><q id='tZPcR'></q></dir></style></legend>

      Android - 键盘未出现在浮动窗口中

      Android - Keyboard not appearing in floating window(Android - 键盘未出现在浮动窗口中)
      <tfoot id='ghqCL'></tfoot>

          <tbody id='ghqCL'></tbody>
      • <legend id='ghqCL'><style id='ghqCL'><dir id='ghqCL'><q id='ghqCL'></q></dir></style></legend>

        <small id='ghqCL'></small><noframes id='ghqCL'>

          <bdo id='ghqCL'></bdo><ul id='ghqCL'></ul>

          <i id='ghqCL'><tr id='ghqCL'><dt id='ghqCL'><q id='ghqCL'><span id='ghqCL'><b id='ghqCL'><form id='ghqCL'><ins id='ghqCL'></ins><ul id='ghqCL'></ul><sub id='ghqCL'></sub></form><legend id='ghqCL'></legend><bdo id='ghqCL'><pre id='ghqCL'><center id='ghqCL'></center></pre></bdo></b><th id='ghqCL'></th></span></q></dt></tr></i><div id='ghqCL'><tfoot id='ghqCL'></tfoot><dl id='ghqCL'><fieldset id='ghqCL'></fieldset></dl></div>
                本文介绍了Android - 键盘未出现在浮动窗口中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在编写一个应用程序,它使用以下代码在正在运行的应用程序的屏幕上绘制编辑文本:

                I'm writing an application that uses the following code to draw an edittext on the screen over running applications:

                WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                                WindowManager.LayoutParams.WRAP_CONTENT,
                                WindowManager.LayoutParams.WRAP_CONTENT,
                                WindowManager.LayoutParams.TYPE_PHONE,
                                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                                    | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                                PixelFormat.TRANSLUCENT);
                
                windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
                
                windowManager.addView(mEditText, params);
                

                edittext的xml是:

                The xml for the edittext is:

                <EditText
                            android:id="@+id/mEditText"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:maxLines="3"
                            android:inputType="textAutoComplete|text"
                            android:focusable="true"
                            android:focusableInTouchMode="true" />
                

                但是,专注于此并不会调出键盘.我还尝试通过 onFocusListener 以编程方式提出它:

                However focusing on this does not bring up the keyboard. I've also tried programmatically bringing it up with an onFocusListener:

                mEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                            @Override
                            public void onFocusChange(View v, boolean hasFocus) {
                                if(hasFocus) {
                                    Log.d("", "Has focus");
                                    ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
                                } else {
                                    Log.d("", "Lost focus");
                                }
                            }
                        });
                

                但是,从 logcat 中可以看出,尽管调用了它,但什么也没发生.到目前为止,我发现显示键盘的唯一方法是使用:

                But although that is called, as seen from the logcat, nothing happens. The only method I've found so far to display the keyboard is using:

                getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0, 0);
                

                但这似乎是在屏幕上输入而不是在编辑文本中.当显示编辑文本时,我也尝试过清晰可聚焦,但无济于事.

                But that seems to type onto the screen and not into the edittext. I've also tried clear focusable when the edittext is displayed but to no avail.

                我猜这个问题是因为我使用的是浮动窗口",但必须有一种方法可以使这项工作成为可能,因为 Playstore 中存在浮动计算器等应用程序,它们需要输入.有人有什么想法吗?我被难住了:(

                I'm guessing the issue is because I'm using a "floating window" but there must be a way to make this work as apps such as floating calculators exist on the playstore which take input.. Anyone have any ideas? I'm stumped :(

                推荐答案

                我的错.. 我意识到如果我删除 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 它可以正常工作.. 愚蠢的错误

                My bad.. I realized if I remove the WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE it works fine.. silly mistake

                这篇关于Android - 键盘未出现在浮动窗口中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                      <bdo id='ujXYK'></bdo><ul id='ujXYK'></ul>
                      <i id='ujXYK'><tr id='ujXYK'><dt id='ujXYK'><q id='ujXYK'><span id='ujXYK'><b id='ujXYK'><form id='ujXYK'><ins id='ujXYK'></ins><ul id='ujXYK'></ul><sub id='ujXYK'></sub></form><legend id='ujXYK'></legend><bdo id='ujXYK'><pre id='ujXYK'><center id='ujXYK'></center></pre></bdo></b><th id='ujXYK'></th></span></q></dt></tr></i><div id='ujXYK'><tfoot id='ujXYK'></tfoot><dl id='ujXYK'><fieldset id='ujXYK'></fieldset></dl></div>
                      <legend id='ujXYK'><style id='ujXYK'><dir id='ujXYK'><q id='ujXYK'></q></dir></style></legend>

                      <small id='ujXYK'></small><noframes id='ujXYK'>

                      <tfoot id='ujXYK'></tfoot>
                        <tbody id='ujXYK'></tbody>