在ListActivity ListView控件编辑文字失去焦点时,键盘出现 [英] Edit Text in ListActivity ListView loses focus when keyboard comes up

查看:249
本文介绍了在ListActivity ListView控件编辑文字失去焦点时,键盘出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已搜查,搜查一个回答这个问题,一切看起来像一个答案没有工作,所以我想我会只问。

I have searched and searched for an answer to this question and everything that looked like an answer has not worked so I guess I will just ask.

我有几个的EditText 添加到箱子一个的ListView 这是基于一 ListActivity 。当我设置了 windowSoftInputMode adjustPan 并单击在的EditText 它的工作原理,直到你再次点击它,然后在键盘盖起来。当我使用 adjustResize 它的工作原理除了当键盘出现的的EditText 失去焦点,我要再次轻触输入。

I have a couple of EditText boxes added to a ListView that is the basis to a ListActivity. When I set the windowSoftInputMode to adjustPan and click in an EditText it works until you click on it again and then the keyboard covers it up. When I use adjustResize it works except when the keyboard comes up the EditText loses focus and I have to tap on it again to type.

我试图找出如何捕捉到 onResize受到但是,这似乎是与视图,而不是活性有关,我不完全知道如何倾听为了它。我也尝试过各种关于的EditText 箱和可聚焦设置的ListView 本身(如在其他职位,建议我读)也似乎并没有帮助的。

I was trying to figure out how to catch the onResize but that seems to be associated with the View and not the activity and I'm not entirely sure how to listen for it. I have also tried all sorts of focusable settings on the EditText boxes and the ListView itself (as suggested in other posts I read) that don't seem to help either.

推荐答案

您真正需要做的是应用到您的ListView:

All you really need to do is apply this to your ListView:

XML:

android:descendantFocusability="afterDescendants"

Java的:

listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

这篇关于在ListActivity ListView控件编辑文字失去焦点时,键盘出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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