Android EditText控件圆满实现只读(Read-Only/Non-Editable)

Android EditText控件完美实现只读(Read-Only/Non-Editable)Sets the key listener to be used with this

Android EditText控件完美实现只读(Read-Only/Non-Editable)

Sets the key listener to be used with this TextView. This can be null to disallow user input. Note that this method has significant and subtle interactions with soft keyboards and other input method: see KeyListener.getContentType() for important details. Calling this method will replace the current content type of the text view with the content type returned by the key listener.Be warned that if you want a TextView with a key listener or movement method not to be focusable, or if you want a TextView without a key listener or movement method to be focusable, you must call setFocusable again after calling this to get the focusability back the way you want it.

?

我想, 这也应该是官方方法了, 纳闷为啥网上搜不出来这种解决方法.

另外, setOnKeyListener其实也是可以的

et.setOnKeyListener(new OnKeyListener() {  @Override  public boolean onKey(View v, int keyCode, KeyEvent event) {    return true;  }}); //consume key inputet.setInputType(InputType.TYPE_NULL);//禁止输入法

这种方法只经过粗略测试, 无法确定是否与前一种等价. 既然已经有完美方法了, 忘了它吧.