我想在进入寄存器类之前使用警告对话框。我希望它像密码一样加密
private OnClickListener regTextClick = new View.OnClickListener() {
@Override
public void onClick(View view) {
// Intent intent = new Intent(/*MainActivity.this*/view.getContext(), Register.class);
// startActivity(intent);
final EditText txtUrl = new EditText(this);
new AlertDialog.Builder(this)
.setTitle("Moustachify Link")
.setMessage("Paste in the link of an image to moustachify!")
09.
.setView(txtUrl)
.setPositiveButton("Moustachify", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String url = txtUrl.getText().toString();
moustachify(null, url);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
.show();
}
};
我认为我的代码错了。我不知道如何使用警报对话框。
答案 0 :(得分:0)
您可以在对话框中设置要显示的editText的输入类型,如下所示:
@Override
public void onClick(View view) {
// Intent intent = new Intent(/*MainActivity.this*/view.getContext(), Register.class);
// startActivity(intent);
final EditText txtUrl = new EditText(this);
txtUrl.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
new AlertDialog.Builder(this)
.setTitle("Moustachify Link")
.setMessage("Paste in the link of an image to moustachify!")
09.
.setView(txtUrl)
.setPositiveButton("Moustachify", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String url = txtUrl.getText().toString();
moustachify(null, url);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
.show();
}
};