問題描述
我需要在我的 Android 應(yīng)用程序中創(chuàng)建一個(gè)包含用戶名"密碼"字段和登錄"和取消"兩個(gè)按鈕的登錄表單.
I need to create a login form with 'username' 'password' fields and two buttons 'login' and 'cancel' in my android application.
我正在使用一個(gè)帶有 edittext 的警報(bào)對(duì)話框.
I am using an alert dialog with edittext inside that.
這是我用來創(chuàng)建密碼編輯文本的代碼..
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);
我的問題是,當(dāng)我打開軟鍵盤編輯密碼時(shí),顯示的是純文本而不是點(diǎn)".(不處于軟鍵盤模式時(shí)顯示為點(diǎn))
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);
這個(gè)對(duì)我有用.
但是你必須看看 Octavian Damiean 的評(píng)論,他是對(duì)的.
This one works for me.
But you have to look at Octavian Damiean's comment, he's right.
這篇關(guān)于Android:如何在編輯文本中設(shè)置密碼屬性?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!