- new AlertDialog.Builder(AlertDialougesActivity.this).setTitle("Test Dialog").setMessage("This is just for Testing..!").setNeutralButton("Close", null).show();
Would
produce this alert:
We have three types of buttons :
- setPositiveButton
Describes an intended action or a confirmation, e.g. “Save” or “Yes”.
- setNeutralButton
Describes a “neutral” action such as “Close”.
- setNegativeButton
Describes a cancellation or simply a “No”.
new
AlertDialog.Builder(AlertDialougesActivity.this).setTitle("Test
Dialog").setMessage("This
is just for Testing..!").setNegativeButton("Cancel",
null).setPositiveButton("OK",
null).setNeutralButton("No",
null).show();
Would
produce this alert:
And
always remember to create at least one button so your dialog can be
closed, otherwise you’ll have frustrated users seeing this:
Finally,
another popular method is setIcon(int
resourceId).
It should be self-explanatory:
new
AlertDialog.Builder(AlertDialougesActivity.this).setTitle("Test
Dialog").setMessage("This
is just for
Testing..!").setIcon(R.drawable.ic_launcher).setNeutralButton("Close",
null).show();
Would
produce this alert:
No comments:
Post a Comment