2017-04-11 62 views
0

我有一個科爾多瓦android應用程序。 我試圖阻止原生android鍵盤顯示當用戶點擊html輸入,或輸入獲取焦點編程。 它有這樣的機器人的東西:如何檢測android軟鍵盤「將顯示」事件

keyboard.addEventListener('will-show', 
    functon(event){ 
    event.disableKeyboardShow(); 
}); 

在此先感謝!

回答

0

我不知道是否有像你指出的事件。但是你可以這樣做防止鍵盤showup自動:

1)將您的onCreate():

InputMethodManager imm = (InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE); 
    View view = this.getCurrentFocus(); 
    if (view == null) { 
     view = new View(this); 
    } 
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 

2)然後,你需要的時候通過增加android:focusable="true"android:focusableInTouchMode="true"元素保證您的EditText能夠獲得焦點在EditText上的這樣的父佈局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linearLayout" android:focusable="true" android:focusableInTouchMode="true"> 

如果你不想讓你的EditText得到反正重點,把false在元素上的步驟2,插入其它:android:descendantFocusability="blocksDescendants"

+0

這種情況是,我只有web瀏覽器的HTML hage裏面,我需要禁用鍵盤時,用戶點擊常規html輸入,textarea(不是本機android的EditText) –

+0

@junior dev你沒有說任何關於webview和HTML直到現在! :((((((((((((((恭喜你一次性考慮!!!初中三年級初級英語初中三年級考試初級三年級初級智商初級三年級初中三年級初中三年級初級初中生喜歡小輩會活下去 – statosdotcom

相關問題