Posts

Showing posts with the label Android - Alert Dialog Tutorial

Android - Alert Dialog Tutorial

Image
A Dialog is small window that prompts the user to a decision or enter additional information. Some times in your application, if you wanted to ask the user about taking a decision between yes or no in response of any particular action taken by the user, by remaining in the same activity and without changing the screen, you can use Alert Dialog. In order to make an alert dialog, you need to make an object of AlertDialogBuilder which an inner class of AlertDialog. Its syntax is given below AlertDialog . Builder alertDialogBuilder = new AlertDialog . Builder ( this ); Now you have to set the positive (yes) or negative (no) button using the object of the AlertDialogBuilder class. Its syntax is alertDialogBuilder . setPositiveButton ( CharSequence text , DialogInterface . OnClickListener listener ) alertDialogBuilder . setNegativeButton ( CharSequence text , DialogInterface . OnClickListener listener ) Apart from this , you can use other functions provided by the bui...