ListView 内的 EditText 不会保持焦点

EditText inside ListView will not stay focused(ListView 内的 EditText 不会保持焦点)
本文介绍了ListView 内的 EditText 不会保持焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 ListView 的每一行内都有一个 EditText.出于某种原因,当我点击 EditText 时,它会短暂获得焦点,但随后立即失去焦点.

I have an EditText inside each row of a ListView. For some reason, when I tap the EditText, it briefly gains focus but then immediately loses it.

我已经尝试过这些事情:

I have tried these things:

listView.setItemsCanFocus(true);
editText.setFocusable(true);


EditText (简要)聚焦时,Enter 键表示 Next 并且存在 auto-correct bar.当它失去焦点时,软键盘保持向上,但Enter键变成Return Arrow自动更正条消失.


While the EditText is (briefly) focused, the Enter key says Next and the auto-correct bar is present. When it loses focus, the soft keyboard stays up, but the Enter key becomes a Return Arrow, and the auto-correct bar disappears.

推荐答案

ListView 中的EditText 非常棘手.如果可能的话,我建议你像避免瘟疫一样避免它们.当我与他们相处时,this answer 很有帮助.如果你只有几个项目,你总是可以只使用 ScrollView.

EditTexts within ListViews are extremely tricky. I'd suggest you avoid them like the plague if possible. When I was messing with them, this answer was helpful though. If you only have a few items you can always just use a ScrollView.

这篇关于ListView 内的 EditText 不会保持焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Prevent enter key on EditText but still show the text as multi-line(防止在 EditText 上输入键,但仍将文本显示为多行)
Android keyboard next button issue on EditText(EditText上的Android键盘下一个按钮问题)
When the soft keyboard appears, it makes my EditText field lose focus(当软键盘出现时,它使我的 EditText 字段失去焦点)
android how to make text in an edittext exactly fixed lines(android如何在edittext中制作文本完全固定的行)
How to use regular expression in Android(如何在 Android 中使用正则表达式)
Filter list view from edit text(从编辑文本中过滤列表视图)