Android中EditText實(shí)現(xiàn)不可編輯解決辦法
android:editable is deprecated: Use an <EditText> to make it editable
android:editable is deprecated: Use inputType instead
分析:關(guān)于EditText控件的read-only問題,即: 無法通過UI更改其中的內(nèi)容, 但可以選定部分內(nèi)容, 進(jìn)行復(fù)制.在早期的sdk, EditText有Editable屬性, 現(xiàn)在這個(gè)屬性已經(jīng)deprecated了.
解決方法:
其實(shí)只需一行代碼就能搞定et.setKeyListener(null);
注意, 這里不是setOnKeyListener, 而是setKeyListener. 此方法是TextView的成員, 調(diào)用后的效果完全符合預(yù)期, 并且獲得焦點(diǎn)后不會(huì)彈出輸入法.
下面是官方文檔的解釋
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.
相關(guān)文章
Android中使用二級(jí)緩存、異步加載批量加載圖片完整案例
這篇文章主要介紹了Android中使用二級(jí)緩存、異步加載批量加載圖片完整案例,本文講解了實(shí)現(xiàn)的過程以及核心代碼展示,并給出了完整項(xiàng)目源碼,需要的朋友可以參考下2015-06-06
android FM播放時(shí)拔出耳機(jī)后FM APP自動(dòng)close解決方法
android FM播放時(shí)拔出耳機(jī)后FM APP自動(dòng)close關(guān)閉的情況應(yīng)該怎樣解決呢?下面為大家詳細(xì)介紹下具體修改方法,感興趣的朋友可以參考下2013-06-06
Android即時(shí)通訊設(shè)計(jì)(騰訊IM接入和WebSocket接入)
本文主要介紹了Android即時(shí)通訊設(shè)計(jì)(騰訊IM接入和WebSocket接入),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04
解決Android studio 2.3升級(jí)到Android studio 3.0 后apt報(bào)錯(cuò)問題
原來項(xiàng)目在Android studio 2.3一切正常,升級(jí)到了3.0之后報(bào)錯(cuò),不支持apt了,其實(shí)解決這個(gè)問題很簡單,只需要修改兩點(diǎn)內(nèi)容就可以,下面腳本之家小編帶領(lǐng)大家通過本文學(xué)習(xí)吧2017-12-12
Android實(shí)現(xiàn)文字上下滾動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)文字上下滾動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12
Android RecyclerView添加頭部和底部實(shí)例詳解
這篇文章主要介紹了Android RecyclerView添加頭部和底部實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-06-06
Android TextView跑馬燈效果實(shí)現(xiàn)方法
這篇文章主要介紹了Android TextView跑馬燈效果實(shí)現(xiàn)方法,涉及Android布局文件中相關(guān)屬性的設(shè)置技巧,非常簡單實(shí)用,需要的朋友可以參考下2016-01-01

