問題:android:editable is deprecated: Use an to make it editable
意思:Android的:編輯是反對:使用<</span> EditText >對其編輯
分析:關於EditText控件的read-only問題,即: 無法通過UI更改其中的內容, 但可以選定部分內容, 進行復制.在早期的sdk, EditText有Editable屬性, 現在這個屬性已經deprecated了.
解決方法:
其實只需一行代碼就能搞定et.setKeyListener(null);
注意, 這裡不是setOnKeyListener, 而是setKeyListener. 此方法是TextView的成員, 調用後的效果完全符合預期, 並且獲得焦點後不會彈出輸入法.
下面是官方文檔的解釋
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.