本文介紹了如何使 EditText 不可編輯/禁用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個 EditText,用戶不應該在其中提供輸入.所以我嘗試禁用它,通過
I have a EditText in which the user should not be able to provide input. So I tried disabling it,by
edittext.setEnabled(false);
edittext.setClickable(false);
但是,當我從其他一些 EditText 按下 softKeyboard 中的下一步"按鈕時,它仍會將我引導到不應編輯的那個,并且我可以將值插入其中.如何避免這種情況?
But still when I press the "next" button in the softKeyboard from some other EditText it directs me to the one which should not be editable and I am able to insert values into it. How to avoid this?
推薦答案
這很好用;只需將 edittext 的 focusable 屬性設置為false"即可.
This works fine; just set focusable property of your edittext to "false" and you are done.
<EditText
android:id="@+id/EditTextInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="right"
android:cursorVisible="true">
</EditText>
這篇關于如何使 EditText 不可編輯/禁用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!