本文介绍了我想告诉OK,并在我的提醒对话框中取消按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示OK,并在我的提醒取消按钮dialog.I尝试了许多解决方案,但没有succeede..guide我plese..thanks

  AlertDialog.Builder建设者=新AlertDialog.Builder(本);
            builder.setMessage(检查您的Internet连接!!你没有连接到互联网。);            AlertDialog警报= builder.create();
                             alert.show();}


解决方案

  AlertDialog.Builder ADB =新AlertDialog.Builder(本);
    adb.setView(alertDialogView);
    adb.setTitle(警告对话框标题);
    adb.setIcon(android.R.drawable.ic_dialog_alert);
    adb.setPositiveButton(OK,新DialogInterface.OnClickListener(){
        公共无效的onClick(DialogInterface对话,诠释它){
            等的EditText =(EditText上)alertDialogView.findViewById(R.id.EditText1);
            Toast.makeText(Tutoriel18_Android.this,et.getText(),Toast.LENGTH_SHORT).show();
      }});
    adb.setNegativeButton(取消,新DialogInterface.OnClickListener(){
        公共无效的onClick(DialogInterface对话,诠释它){            完();
      }});
    adb.show();

I want to show ok and cancel button in my alert dialog.I tried many solutions but didnt succeede..guide me plese..thanks

AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Check Your Internet Connection!! you are not connected to the Internet..");

            AlertDialog alert = builder.create();
                             alert.show();} 
解决方案
    AlertDialog.Builder adb = new AlertDialog.Builder(this);


    adb.setView(alertDialogView);


    adb.setTitle("Title of alert dialog");


    adb.setIcon(android.R.drawable.ic_dialog_alert);


    adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {


            EditText et = (EditText)alertDialogView.findViewById(R.id.EditText1);


            Toast.makeText(Tutoriel18_Android.this, et.getText(), Toast.LENGTH_SHORT).show();
      } });


    adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            finish();
      } });
    adb.show();

这篇关于我想告诉OK,并在我的提醒对话框中取消按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 19:30