本文介紹了如何使 EditText 不可編輯/禁用的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我有一個(gè) EditText,用戶不應(yīng)該在其中提供輸入.所以我嘗試禁用它,通過
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);
但是,當(dāng)我從其他一些 EditText 按下 softKeyboard 中的下一步"按鈕時(shí),它仍會(huì)將我引導(dǎo)到不應(yīng)編輯的那個(gè),并且我可以將值插入其中.如何避免這種情況?
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 屬性設(shè)置為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>
這篇關(guān)于如何使 EditText 不可編輯/禁用的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!