如何在此处将文本框设为密码类型?我使用下面的代码,但它不起作用。
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setTitle("Verification");
alert.setMessage("Enter your Verification Code");
alert.setCancelable(false);
final EditText encrypt = new EditText(getActivity());
encrypt.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
alert.setView(encrypt);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
答案 0 :(得分:2)
试试这个:
encrypt.setTransformationMethod(PasswordTransformationMethod.getInstance());
答案 1 :(得分:1)
如果这应该是密码输入视图,您应该像这样设置:
encrypt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);