2017-08-15 66 views
-6

我試圖把數字點擊和關閉鍵盤,因爲只需要一個號碼,我不知道該怎麼做!當點擊數字鍵盤關閉鍵盤,並把號碼

< - 編輯 - >

對不起,我的解釋,如果不夠,我必須把分數套,像捷尼斯,其多達7個的allmost,然後用一個關鍵的是,我有數字鍵盤,到這裏完美的,但我想點擊一個號碼並關閉鍵盤數量EDITTEXT場

+0

'我不知道該怎麼辦了!'你不知道該怎麼辦到底是什麼?如何檢測1符號是鍵入?如何隱藏鍵盤?如何製作Android程序?請更具體一些。 –

回答

0

要關閉鍵盤:

// Check if no view has focus: 
View view = this.getCurrentFocus(); 
if (view != null) { 
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 
} 

,並設置數鍵入您使用editText's Listerners

0

使用ontextchangedListener該文本框像下面

editText.addTextChangedListener(new TextWatcher() { 

    public void afterTextChanged(Editable s) {} 

    public void beforeTextChanged(CharSequence s, int start, 
     int count, int after) { 
    } 

    public void onTextChanged(CharSequence s, int start, 
     //place neccessary logic here and close the keyboard 
    } 
});