create Warning Alert Dialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

create Warning Alert Dialog

Demo Code


import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Main{
    public static AlertDialog createWarningDialog(Context context,
            String title, String message,
            DialogInterface.OnClickListener listener) {
        AlertDialog alert = new AlertDialog.Builder(context).create();
        alert.setIcon(android.R.drawable.ic_dialog_alert);
        alert.setTitle(title);/*from  www  . j  a v  a  2 s. co  m*/
        alert.setMessage(message);
        alert.setInverseBackgroundForced(true);
        alert.setCancelable(false);
        alert.setButton(AlertDialog.BUTTON_POSITIVE,
                context.getString(R.string.ok), listener);
        alert.setButton(AlertDialog.BUTTON_NEGATIVE,
                context.getString(R.string.cancel), listener);
        return alert;
    }
}

Related Tutorials