How to Show an Complete Alert Dialog in android studio

Alert Dialog is best way to notify user about something . here we are create a simple complete task dialog basic code block



Step 1: Crate a backgorund.xml drawable file for a round background on complete backgorund_workout_discription.xml

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/color_white"></solid>
    <corners
       android:radius="10dp"></corners>
</shape>

Step :2 Call this Method when You want to call Complete dialog

  private void completeDialog()
        AlertDialog dialog;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);

        builder.setTitle(getResources().getString(R.string.completed));
        builder.setIcon(getResources().getDrawable(R.drawable.ic_complete_mark_24));

        builder.setMessage(getResources().getString(R.string.completed_dicription));
        builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }

        });
        builder.setPositiveButton(getResources().getString(R.string.diet), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
             // do anything in positive button 
            }
        });
        dialog = builder.create();
        dialog.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.backgorund_workout_discription));
        dialog.show();

    }
      

Thank You Keep Learning Keep Connected #AndroidShortCode

Comments