Android 输入警报对话框
我想在进入register类之前使用alert对话框。我希望它像密码一样加密Android 输入警报对话框,android,android-alertdialog,Android,Android Alertdialog,我想在进入register类之前使用alert对话框。我希望它像密码一样加密 private OnClickListener regTextClick = new View.OnClickListener() { @Override public void onClick(View view) { // Intent intent = new Intent(/*MainActivity.this*/view.getContext(),
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();
}
};
我想我的代码错了。我不知道如何使用警报对话框。您可以设置对话框中显示的编辑文本的输入类型,如下所示:
@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();
}
};
您可以为edittext设置输入类型。如果有一些文本解释它们解决问题的原因,那么答案总是非常有用。