android – requestFocus跳过下一个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>

解决方法

这似乎是一个已知问题.以下关于Android项目的Google代码的帖子描述了同样的问题.

Issue 2705: Setting requestFocus on EditText prevents soft keyboard from opening

您可以尝试在代码中而不是在布局中设置焦点.

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...