問題描述
我有一個 Activity
,其中有 5 個 EditText
.當用戶單擊第一個 EditText
時,軟鍵盤打開以在其中輸入一些值.我想在軟鍵盤打開時以及當用戶單擊第一個 EditText
時將其他一些 View
的可見性設置為 Gone
以及當軟鍵盤在后退按鈕按下時從相同的 EditText
關閉時.然后我想將其他一些 View
的可見性設置為可見.
I have an Activity
where there are 5 EditText
s. When the user clicks on the first EditText
, the soft keyboard opens to enter some value in it. I want to set some other View
's visibility to Gone
when the soft keyboard opens and also when the user clicks on the first EditText
and also when the soft keyboard closes from the same EditText
on the back button press. Then I want to set some other View
's visibility to visible.
當軟鍵盤通過點擊 Android 中的第一個 EditText
打開時,是否有任何監聽器或回調或任何 hack?
Is there any listener or callback or any hack for when the soft keyboard opens from a click on the first EditText
in Android?
推薦答案
小菜一碟KeyboardVisibilityEvent 庫
KeyboardVisibilityEvent.setEventListener(
getActivity(),
new KeyboardVisibilityEventListener() {
@Override
public void onVisibilityChanged(boolean isOpen) {
// Ah... at last. do your thing :)
}
});
清水康弘的作品
這篇關于軟鍵盤在Android中的活動中打開和關閉監聽器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!