requestFocus的跳绳接下来的EditText [英] requestFocus skipping next EditText
问题描述
我有一些问题,控制重点。我下面的接口定义有:
源(RadioGroup中/可选) 目的地(EditText上) 量(EditText上) 传递(按钮)
我改变的源的洞察我的code。当时候,我不显示它,焦点会自动进入量而我希望这是目标来代替。我不知道我错过了什么。我怀疑这可能是一个Android的错误,我不知道。有没有人知道如何解决这个问题?
感谢
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
< RadioGroup中机器人:ID =@ + ID /源
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直
机器人:能见度=水涨船高>
<单选机器人:ID =@ + ID /默认
机器人:检查=假
机器人:文本=@字符串/默认的/>
< / RadioGroup中>
< TableLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:stretchColumns =1>
<的TableRow>
<的TextView
机器人:文本=@字符串/目的地
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:TEXTSIZE =16SP
机器人:文字颜色=#FFFFFF
机器人:paddingRight =10SP
机器人:layout_weight =1/>
< EditText上机器人:ID =@ + ID /目标
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:单线=真正的><不是requestFocus />< /的EditText>
< /的TableRow>
<的TableRow>
<的TextView
机器人:文本=@字符串/数量
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:TEXTSIZE =16SP
机器人:文字颜色=#FFFFFF
机器人:paddingRight =10SP
机器人:layout_weight =1/>
< EditText上机器人:ID =@ + ID /数量
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:单线=真/>
< /的TableRow>
< / TableLayout>
<按钮机器人:ID =@ + ID /传输
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/传输/>
< / LinearLayout中>
这似乎是一个已知的问题。下面的职位上谷歌code的Android项目描述了同样的问题。
问题2705:在设置不是requestFocus的EditText prevents软键盘无法打开
您可以尝试将焦点设置在code,而不是在布局。
I'm having some problems with the control focusing. My interface definition below has:
source (RadioGroup/optional) destination (EditText) quantity (EditText) transfer (Button)
I'm changing the visibility of the "source" into my code. When the times I don't display it, focus is automatically goes to "quantity" which I would expect that to be "destination" instead. I don't know what I'm missing. I suspect it could be an Android bug, I don't know. Is there anybody know how to solve this?
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>
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.
这篇关于requestFocus的跳绳接下来的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!