编辑文本在滚动时失去焦点

3
我有一个页面上有多个编辑文本框和下拉框。为了启用滚动,我在清单文件中的活动中加入了 android:windowSoftInputMode="adjustResize"。但是当我滚动视图时,我的聚焦的编辑文本框就失去了焦点。也就是说,假设我第一个编辑文本框已经聚焦,然后我向下滚动,再回到第一个编辑文本框,但此时我的第一个编辑文本框已经失去了焦点。有趣的是,当我在API级别4.0中测试相同的事情时,它能正常工作,而在4.0之前则不能。
请帮忙告诉我该怎么做或建议我遗漏的东西。
至于代码,只是一些正在工作的编辑文本框。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>



        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/hello" />

            <EditText
                android:id="@+id/et_user"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:singleLine="true" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>
1个回答

0

这就是Android所提供的,也许有一些变通方法,但目前它就是这样工作的。所以我能告诉你的是要遵守这个限制。如果有任何更新,我会通知你。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接