Alert Dialog in Android
Alert Dialog in Android In some conditions in your application you ask the decisions of user like yes or no. By taking the user response in the same activity and within changing the screen(activity) you can use a alert dialog. Create a new project in Android Studio. File --> New Android -->Application Project Next, Select Target Device After that, Select Activity And then Click finish. * For, alert dialog you need to create a object of AlertDialogBuilder which an inner class of AlertDialog. see below, AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); Then, you have to set yes or no buttons like this: alertDialogBuilder.setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener) alertDialogBuilder.setNegativeButton(CharSequence text, DialogInterface.OnClickListener listener) For 2 Buttons(Yes or no): activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <Relat...