EditText上出现松动键盘时,重点;需要触摸两次修改 [英] EditText looses focus when keyboard appears; requires touching twice to edit

查看:157
本文介绍了EditText上出现松动键盘时,重点;需要触摸两次修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在设计其持有的可扩展列表的应用程序。在每个列表的末尾,一个空的的EditText 已准备好接收意见。我有以下的问题;当我触摸的EditText ,屏幕略微调整大小(不是一个问题,调整大小并不总是发生,这取决于我的布局和位置的出现的EditText 诠释他的列表)和软键盘。然而,在这些事件中,的EditText 失去焦点并没有恢复它。这是非常不方便的是没有焦点,尽管键盘是可用的,从键盘输入没有达到的EditText 。有一次,我再触摸它时,的EditText 行为与预期相同。

I have been designing an application which holds an expandable list. At the end of every list, an empty EditText is ready to receive comments. I have the following problem; when I touch the EditText, the screen resizes slightly (not a problem as the resizing does not always happen, depending on my layout and the position of the EditText int he list) and the soft-keyboard appears. However, during these events, the EditText looses focus and does not regain it. This is quite inconvenient as without focus, despite the keyboard being available, the input from the keyboard does not reach the EditText. Once I touch it again, the EditText behaves as expected.

它会变得陌生了。用键盘仍显示,我可以触摸不同的的EditText 键,同样的情况;它失去焦点。但是,一旦我通过聚焦的初始损失,我可以自由previously触及的EditText 秒之间将没有任何焦点相关的问题。只有当我隐藏软键盘将国家消失,我需要点击的EditText S是能够编辑之前的两倍。

It gets even stranger. With the keyboard still displayed, I can touch a different EditText and the same happens; it looses focus. However, once I passed the initial loss of focus, I can move freely between previously touched EditTexts without any focus related issues. Only when I hide the soft-keyboard will the "state" disappear and I would need to tap EditTexts twice before being able to edit them.

下面是从我的code摘录。首先, empty_comment.xml

Here are excerpts from my code. First, the empty_comment.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<EditText
    android:id="@+id/blank_box"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textCapSentences"
    android:imeOptions="actionDone"
    android:hint="@string/hint"
    android:layout_marginLeft="30dip" >
</EditText>
</LinearLayout>

下面从我使用的布局有问题的片段摘录:

Here an excerpt from the fragment where I use the layout in question:

convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_empty, null);
final EditText editText = (EditText) convertView.findViewById(R.id.blank_box);
editText.setOnEditorActionListener(new OnEditorActionListener()
{   
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
    {
        if(actionId == EditorInfo.IME_ACTION_DONE)
        {
            // Unrelated code
        }
        return true;
    }
});

我不指定任何特定的输入在我的清单文件,但我可以提供,如果认为有帮助的。

I am not specifying anything input specific in my manifest file but I could provide it if deemed helpful.

更新:

添加一行到活动调整声像安卓windowSoftInputMode =adjustPan并部分解决问题。它取代与的EditText 的意见可能会隐藏在软键盘的问题,当前的异常行为。

Adding a line to the Activity to adjust the pan android:windowSoftInputMode="adjustPan" does partially solve the problem. It replaces the current unexpected behaviour with the problem that EditText views might get hidden by the soft-keyboard.

截至目前,没有理想的解决方案已被找到,但走近。看看在接受答案的评论,他们可能被证明对你有用!

As of now, no ideal solution has been found but approached. Have a look at the comments in the accepted answer, they might prove useful to you!

推荐答案

您需要在AndroidManifest.xml中更改

You need to change in your AndroidManifest.xml

添加安卓windowSoftInputMode =adjustPan在活动举办的列表视图。这将解决您的问题。

Add android:windowSoftInputMode="adjustPan" in the activity holding the listview. This will solve your problem.

<activity android:name=".MyEditTextInListView"
          android:label="@string/app_name"
          android:windowSoftInputMode="adjustPan">

这篇关于EditText上出现松动键盘时,重点;需要触摸两次修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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