ExpandableListView子项的EditText上不能保持专注 [英] ExpandableListView child item's EditText can't keep focus

查看:942
本文介绍了ExpandableListView子项的EditText上不能保持专注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个ExpandableListView有相当复杂的子项的XML。它包含一个TextView,一个复选框和一个EditText。部分原因是如下:

I created an ExpandableListView with a quite complex child item xml. It contains a TextView, a Checkbox and an EditText. Part of it is below:

 <TableLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="horizontal"
               android:stretchColumns="1">
    <TableRow>
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      >
      <TextView
          android:id="@+id/lblData1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="14dip"
          android:paddingTop="2dp"
          android:layout_marginLeft="4dp"
          android:text="@string/lblTitle1"
          android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"/>
      <EditText android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:selectAllOnFocus="true">

      </EditText>
    </TableRow>
  </TableLayout>

在ListView显示的列表好了,我可以看到他们的相应部件我孩子的物品,但是当我点击的EditText里面,它第二次显示的键盘分割和的焦点前进到下一个儿童和隐藏键盘的(聚焦丢失,不移动到下一个的EditText)

The listview displays the list well, I can see my child items with their corresponding widgets but when I click inside the EditText, it displays the keyboard for a split second and the focus advances to the next child and hides the keyboard (the focus is lost, not moving to the next EditText).

我如何prevent是什么?我想写出EditTexts中的文本。

How can I prevent that? I'd like to write text inside the EditTexts.

推荐答案

需要两个设置:


  • 在UI code:

  • In the UI code:

expListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

在AndroidManifest.xml中的活动:

In the AndroidManifest.xml for the Activity:

&LT;活动机器人:名字=机器人InfoActivity:windowSoftInputMode =adjustPan&GT;

这篇关于ExpandableListView子项的EditText上不能保持专注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆