Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 输入警报对话框_Android_Android Alertdialog - Fatal编程技术网

Android 输入警报对话框

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(),

我想在进入register类之前使用alert对话框。我希望它像密码一样加密

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设置输入类型。如果有一些文本解释它们解决问题的原因,那么答案总是非常有用。