問題描述
我在 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
.
EditText
s within ListView
s 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 不會保持焦點的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!