Show Success Alert Dialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

Show Success Alert Dialog

Demo Code


//package com.java2s;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Main {
    public static void ShowSuccessAlert(final Context context,
            String heading, String description) {
        new AlertDialog.Builder(context)
                .setTitle(heading)// w w w.ja  va  2  s . co  m
                .setMessage(description)
                .setPositiveButton(android.R.string.yes,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int which) {
                                if (!((Activity) context).isFinishing())
                                    ((Activity) context).finish();
                            }
                        }).setIcon(android.R.drawable.ic_dialog_info)
                .show();
    }

    public static void ShowSuccessAlert(final Context context,
            String heading, String description,
            DialogInterface.OnClickListener action) {
        new AlertDialog.Builder(context).setTitle(heading)
                .setMessage(description)
                .setPositiveButton(android.R.string.yes, action)
                .setIcon(android.R.drawable.ic_dialog_info).show();
    }
}

Related Tutorials