2016-04-14 82 views
2

我有一个EditText,我想我的应用程序永远不会显示软键盘,当我专注于它。我正在使用外接键盘。TextView setShowSoftInputOnFocus相当于SDK 21之前吗?

我想做到这一点,我活动的onCreate

EditText debugPrompt = (EditText)findViewById(R.id.debug_prompt); 
debugPrompt.setShowSoftInputOnFocus(false); 

问题是,我使用的SDK 19,并在setShowSoftInputOnFocus 21.加入有什么相同呢?

我最好的尝试迄今:

getWindow().setSoftInputMode(
      WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
EditText debugPrompt = (EditText)findViewById(R.id.debug_prompt); 
debugPrompt.requestFocus(); 

这确实是工作的一部分。键盘在第4行后隐藏,但是当我点击EditText时显示。

+0

我通过升级我的SDK解决了这个问题。对于任何不能升级的开发者来说,答案可能仍然有用。 – dinosaur

回答

0

InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(view.getWindowToken(),0);