里面的EditText的ListView失去焦点 [英] EditText inside ListView lost focus

查看:406
本文介绍了里面的EditText的ListView失去焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近面对这个问题,我想与大家分享我的解决方案。

I have recently face this problem and I want to share with you my solution.

问题

  • 您有对每一行文字编辑这样一个ListView:

MainList.xml

MainList.xml

<ListView
    android:id="@+id/listViewServ"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"/>

RowList.xml

RowList.xml

<TextView 
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="100dp"
        android:layout_height="wrap_content"  
        android:inputType="number"/>

  • 您正在使用TABS: tabHost或TabActivity 。 (这是非常重要的注意)。
  • 当你点击任何一个列表项的EditText,重点移出立即您无法输入任何东西。然而,键盘还亮着。但是,不会出现以往你输入什么为重点丢失。
    • You are working with TABS: tabHost or TabActivity. (this is very important to notice).
    • When you click on any of the list item EditText, the focus moves out immediately and you are not able to type anything. However the keyboard is still on. But what ever you type in does not appear as the focus is lost.
    • 现在,我想给你我的解决方案张贴我自己的问题。

      Now, I'm going to give you my solution posting my own question.

      推荐答案

      我已经看到了一些解决方案使用的是:

      I have seen that some solutions are using:

      android:descendantFocusability="beforeDescendants"
      

      列表中定义的布局。

      in the layout of the definition of the list.

      对于我来说,这是没有必要的。采用了android的问题得到了解决:windowSoftInputMode =adjustPan:

      For me this wasn't necessary. The problem was fixed using android:windowSoftInputMode="adjustPan":

      <activity
              android:name="mainActivity"
              android:windowSoftInputMode="adjustPan"
              android:label="@string/app_name" >
          </activity>
      

      在manifest.xml。

      in the Manifest.xml.

      但是你要确保这条线的code去在您所定义的TabHost或TabActivity活动!!!

      这篇关于里面的EditText的ListView失去焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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