需要在对话框中显示名称

时间:2012-07-29 14:27:00

标签: android

case DIALOG_ID:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        EditText edittext=(EditText)findViewById(R.id.name);
        Appendable name=edittext.getText();
        builder.setMessage(name + " Certificate saved successfully! Would like to add another Certificate?")
        .setCancelable(false)
        .setPositiveButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                SaveData.this.finish();
          }
        })

builder.setMessage我输入了一个名为 name 的字符串,当我在第一次进入对话框时在模拟器中输入名称但是当我在模拟器上将名称更改为其他名称时我首先输入的名称即将到来,它不会更改为第二个名称

我该怎么做?对我有什么帮助吗?

1 个答案:

答案 0 :(得分:2)

获取String变量并存储edittext ::

中的文本
EditText edittext=(EditText)findViewById(R.id.edittext_for_name);
String name=edittext.getText();

然后:

builder.setMessage(name+ " Certificate saved successfully. Would you like to add another certificate?")