問題描述
我已經(jīng)搜索并搜索了這個問題的答案,但所有看起來像是答案的東西都沒有奏效,所以我想我會問的.
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.
我在 ListView
中添加了幾個 EditText
框,這是 ListActivity
的基礎(chǔ).當(dāng)我將 windowSoftInputMode
設(shè)置為 adjustPan
并單擊 EditText
時,它會起作用,直到您再次單擊它,然后鍵盤將其覆蓋.當(dāng)我使用 adjustResize
時,它可以工作,除非當(dāng)鍵盤出現(xiàn)時 EditText
失去焦點(diǎn),我必須再次點(diǎn)擊它才能輸入.
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
但這似乎與視圖相關(guān)聯(lián),而不是活動,我不完全確定如何聽它.我還嘗試了 EditText
框和 ListView
本身的各種可聚焦設(shè)置(如我閱讀的其他帖子中所建議的那樣),這些設(shè)置似乎也無濟(jì)于事.
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.
推薦答案
您真正需要做的就是將它應(yīng)用到您的 ListView:
All you really need to do is apply this to your ListView:
XML:
android:descendantFocusability="afterDescendants"
Java:
listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
這篇關(guān)于鍵盤出現(xiàn)時 ListActivity 中的編輯文本 ListView 失去焦點(diǎn)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!