我在控制对焦方面遇到一些问题。我的接口定义如下:
来源(无线电组/可选)
目的地(编辑文本)
数量(编辑文本)
转移(按钮)
我正在将“源”的可见性更改为我的代码。当我不显示它时,焦点会自动转到“数量”,我希望它是“目的地”。我不知道我错过了什么。我怀疑这可能是 Android 的 bug,我不知道。有没有人知道如何解决这个问题?
Thanks
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RadioGroup android:id="@+id/source"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<RadioButton android:id="@+id/default"
android:checked="false"
android:text="@string/default"/>
</RadioGroup>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow>
<TextView
android:text="@string/destination"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="#ffffff"
android:paddingRight="10sp"
android:layout_weight="1"/>
<EditText android:id="@+id/destination"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"><requestFocus/></EditText>
</TableRow>
<TableRow>
<TextView
android:text="@string/quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="#ffffff"
android:paddingRight="10sp"
android:layout_weight="1"/>
<EditText android:id="@+id/quantity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"/>
</TableRow>
</TableLayout>
<Button android:id="@+id/transfer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/transfer"/>
</LinearLayout>
这似乎是一个已知问题。以下关于 Android 项目的 google code 的帖子描述了同样的问题。
问题 2705:在 EditText 上设置 requestFocus 会阻止软键盘打开
您可以尝试在代码中而不是在布局中设置焦点。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)