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[] { "pankaj_88_88@yahoo.com" });
s.putExtra(android.content.Intent.EXTRA_SUBJECT,
"feedback from app");
startActivity(s);
break;
}
}
});
AlertDialog alert = builder.create();
alert.setCancelable(true);
alert.show();
}
This code is what you need. Just insert it wherever you need to launch the alert dialog. I haven't figured out how to launch the keyboard automatically , but it shouldn't be difficult.
very simple way for alert message in dialog box...
also you have to create an detail.xml file like this