CopyPastor

Detecting plagiarism made easy.

Score: 0.8094782829284668; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2020-09-24
by mel.j

Original Post

Original - Posted on 2014-06-16
by sanath\_p



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You must call `builder.setPositiveButton` before create `AlertDialogBuilder`.

AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("delete?"); builder.setPositiveButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.setNegativeButton("no", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show();
The code which David Hedlund has posted gave me the error:
> Unable to add window — token null is not valid
If you are getting the same error use the below code. It works!!
runOnUiThread(new Runnable() { @Override public void run() {
if (!isFinishing()){ new AlertDialog.Builder(YourActivity.this) .setTitle("Your Alert") .setMessage("Your Message") .setCancelable(false) .setPositiveButton("ok", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Whatever... } }).show(); } } });

        
Present in both answers; Present only in the new answer; Present only in the old answer;