Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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 在安卓系统中,Can alert对话框可以在运行时更改标题_Android_Android Alertdialog_Android Dialog - Fatal编程技术网

Android 在安卓系统中,Can alert对话框可以在运行时更改标题

Android 在安卓系统中,Can alert对话框可以在运行时更改标题,android,android-alertdialog,android-dialog,Android,Android Alertdialog,Android Dialog,在Android中,我可以在运行时更改对话框的标题吗 AlertDialog.Builder builder; builder = new AlertDialog.Builder(Manage_Holidays.this); builder.setMessage("Are you sure you want to insert new holiday") .setCancelable(false) .setTitle("Confirmation") .setNegativeButton("No"

在Android中,我可以在运行时更改对话框的标题吗

AlertDialog.Builder builder;
builder = new AlertDialog.Builder(Manage_Holidays.this);
builder.setMessage("Are you sure you want to insert new holiday")
.setCancelable(false)
.setTitle("Confirmation")
.setNegativeButton("No",new DialogInterface.OnClickListener() {
    public void onClick(    DialogInterface dialog,int id) {
                   // Title need to changed ass progress                            }})
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
    public void onClick(    DialogInterface dialog,int id) {
    builder.setMessage("Processing...");
    builder.setTitle("dsjc");
    }}).setCancelable(false);
 AlertDialog alert = builder.create();
 alert.show();
在这个例子中,我想在单击yes按钮时显示一个字符串,在单击no按钮时显示另一个字符串=

DialogInterface.OnClickListener dialogClickListener = new  DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
    switch (which){
    case DialogInterface.BUTTON_POSITIVE:
        //Yes button clicked
        break;

    case DialogInterface.BUTTON_NEGATIVE:
        //No button clicked
        break;
    }
}
};

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener).show();

您还可以重用该DialogInterface.OnClickListener,如果您有其他“是/否”框,则无法重用同一警报对话框

 final AlertDialog.Builder builder,anotherbuilder;
     builder = new AlertDialog.Builder(MainView.this);
     anotherbuilder =new AlertDialog.Builder(this);
     builder.setMessage("Are you sure you want to insert new holiday")
     .setCancelable(false)
     .setTitle("Confirmation")
     .setNegativeButton("No",new DialogInterface.OnClickListener() {
         public void onClick(    DialogInterface dialog,int id) {
                        // Title need to changed ass progress                   
             }})
     .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
         public void onClick(    DialogInterface dialog,int id) {
         anotherbuilder.setMessage("Processing...");
         anotherbuilder.setTitle("dsjc");
         AlertDialog alert = anotherbuilder.create();
          alert.show();
         }}).setCancelable(false);


      AlertDialog alert = builder.create();
      alert.show();

运行时意味着???,请提供更多信息。您不能重复使用与您的目的相同的对话框。。。相反,您可以显示另一个包含相应信息和标题的对话框。单击“是”按钮时,将处理某些进程,。。此时标题必须更改为“Progressing!”。..@Gowrishankar:当前您正在设置标题
builder.setTitle(“dsjc”)单击“是”按钮?这不起作用。。。没有出现任何错误消息,标题也没有更改!。。