Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.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 数字编辑文本在listview中首次输入后失去焦点_Android_Android Edittext_Focus - Fatal编程技术网

Android 数字编辑文本在listview中首次输入后失去焦点

Android 数字编辑文本在listview中首次输入后失去焦点,android,android-edittext,focus,Android,Android Edittext,Focus,我的listview中有多个EditText,数字和普通。当我点击一个数字时,它会获得焦点并弹出键盘,但在我输入1个数字后,它会失去焦点,我必须再次点击它来输入更多的数字。有没有办法保持注意力集中,这样我就可以输入更多的数字?我的普通编辑文本工作得很好 我已经尝试过使用adjustpan和不同的键盘模式 编辑文本代码: <EditText android:id="@+id/etEditTextItem" android:inputType="number" andr

我的listview中有多个EditText,数字和普通。当我点击一个数字时,它会获得焦点并弹出键盘,但在我输入1个数字后,它会失去焦点,我必须再次点击它来输入更多的数字。有没有办法保持注意力集中,这样我就可以输入更多的数字?我的普通编辑文本工作得很好

我已经尝试过使用adjustpan和不同的键盘模式

编辑文本代码:

<EditText
    android:id="@+id/etEditTextItem"
    android:inputType="number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="5"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:layout_alignParentRight="true" />

列表视图代码:

         <ExpandableListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@color/colorCard"
            android:groupIndicator="@null">
        </ExpandableListView>

问题在于listview:您必须在listview活动中添加以下内容

android:windowSoftInputMode="adjustPan"
并将以下内容添加到listview

android:descendantFocusability="beforeDescendants"

我设法修复了它,在调试currentFocus之后,我发现listview onExpand()将焦点拿走,在将焦点返回到editText之后设置editText.requestfocus()。

我也有同样的问题,但我的editText不在任何listview中。它只是在几个嵌套的LinearLayout中,并且对于,也放松了它的焦点。解决我的问题的方法是在活动代码和我设置的ContextChanged中为此EditText添加TextChangedListener:

EditText.requestFocusFromTouch()

试过了,输入第一个数字后仍然失去焦点