poc*_*coa 8 android focus android-edittext
我在控制聚焦方面遇到了一些问题.我的界面定义如下:
源(RadioGroup /可选)目标(EditText)数量(EditText)传输(按钮)
我正在将"源"的可见性更改为我的代码.当我没有显示它的时候,焦点会自动转到"数量",我希望它是"目的地".我不知道我错过了什么.我怀疑它可能是一个Android bug,我不知道.有人知道如何解决这个问题吗?
谢谢
<?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>
Run Code Online (Sandbox Code Playgroud)
It appears to be a known issue. The following post on google code for the Android project describes the same problem.
Issue 2705: Setting requestFocus on EditText prevents soft keyboard from opening
You could try setting focus in your code instead of in the layout.
| 归档时间: |
|
| 查看次数: |
22970 次 |
| 最近记录: |