本文介紹了Android:如何在編輯文本中設置密碼屬性?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我需要在我的 Android 應用程序中創建一個包含用戶名"密碼"字段和登錄"和取消"兩個按鈕的登錄表單.
I need to create a login form with 'username' 'password' fields and two buttons 'login' and 'cancel' in my android application.
我正在使用一個帶有 edittext 的警報對話框.
I am using an alert dialog with edittext inside that.
這是我用來創建密碼編輯文本的代碼..
This is the code I used to create password edittext..
final EditText Password = new EditText(this);
Password.setGravity(Gravity.CENTER);
Password.setHint("Password");
Password.setWidth(200);
Password.setTransformationMethod(new PasswordTransformationMethod());
login_alert.addView(Password);
我的問題是,當我打開軟鍵盤編輯密碼時,顯示的是純文本而不是點".(不處于軟鍵盤模式時顯示為點)
My issue is that, plain text is shown instead of 'dots' when i open a softkeypad to edit the password. (It is shown as dots when not in softkeypad mode)
誰能提出解決方案?
推薦答案
Password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
這個對我有用.
但是你必須看看 Octavian Damiean 的評論,他是對的.
This one works for me.
But you have to look at Octavian Damiean's comment, he's right.
這篇關于Android:如何在編輯文本中設置密碼屬性?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!