当软键盘的出现,也让我的EditText字段失去焦点 [英] When the soft keyboard appears, it makes my EditText field lose focus

查看:148
本文介绍了当软键盘的出现,也让我的EditText字段失去焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在ListView少数的EditText领域。当我轻点的EditText领域之一,键盘滑入视图中(因为它应该),但该领域的EditText我拍了拍失去焦点。我一直利用各种InputMethodManager方法,使键盘开始在视图(为了解决这个问题,而不是真正解决它)尝试过,但没有奏效 - 键盘是不是在视图活动时出现了<。 / P>

本的EditText的类型是,当键盘滑动,它是一个数字键盘,但是,当它完成滑动和的EditText失去焦点,它改变字母键盘(这加强了想法,EditText上不再具有焦点)。

我的问题是:

1)如何让我的EditText字段的选择和后续滑动的软键盘的没有的让我的EditText失去焦点?

...做不到这一点......

2)如何让键盘开始时,鉴于这样永远不会滑入(从而避免的行为,我觉得这么反感)?

我的清单中包含了安卓windowSoftInputMode =stateAlwaysVisible,但键盘没有出现,直到我敲击一个EditText。这忽略了stateAlwaysVisible属性似乎只发生在模拟器 - 我的供应设备上,被誉为这样的问题数2上面并在设备上的工作......但不是在模拟器。

感谢您的帮助,您可以提供!

解决方案

这家伙有同样的问题,更之外。他用滚动型和的LinearLayout,而不是一个ListView解决了这个问题。

I've got a few EditText fields in a ListView. When I tap on one of the EditText fields, the keyboard slides into view (as it should), but the EditText field I tapped loses focus. I've tried using various InputMethodManager methods to make the keyboard start out in view (in order to get around the problem rather than truly solve it), but that didn't work - the keyboard was not in view when the Activity appeared.

The EditText's type is number, and when the keyboard is sliding in, it is a number keyboard, but when it finishes sliding and the EditText loses focus, it changes to the alphabetical keyboard (which reinforces the idea that the EditText no longer has focus).

My questions are these:

1) How can I make the selection of my EditText field and the subsequent sliding in of the soft keyboard not make my EditText lose focus?

... failing that...

2) How can I make the keyboard start out in view so it never has to slide in (thus avoiding the behavior I find so objectionable)?

My manifest does include android:windowSoftInputMode="stateAlwaysVisible", but the keyboard does not appear until I tap on an EditText. This ignoring of the 'stateAlwaysVisible' attribute seems to only occur in the emulator - on my provisioned device, it is honored so question number 2 above does work on the device... but not in the emulator.

Thanks for any help you can provide!

解决方案

This guy had the same problem and more besides. He solved it by using a ScrollView and a LinearLayout instead of a ListView.

这篇关于当软键盘的出现,也让我的EditText字段失去焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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