I have a alert dialog box in my code and I want to assign a value to a variable as the cancel button is pressed for that dialog.
My actual code is -
private void clicked() { AlertDialog.Builder builder = new AlertDialog.Builder(Feedback.this); builder.setTitle("FEEDBACK"); builder.setSingleChoiceItems(options, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub switch (which) { case 0: String url = "http://killmathsapp.blogspot.in/"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); break; case 1: Intent s = new Intent(Intent.ACTION_SEND); s.setType("plain/text"); s.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "[email protected]" }); s.putExtra(android.content.Intent.EXTRA_SUBJECT, "feedback from app"); startActivity(s); break; } } }); AlertDialog alert = builder.create(); alert.setCancelable(true); alert.show(); }