create Alert Dialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

create Alert Dialog

Demo Code

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

public class Main{
    public static AlertDialog createAlertDialog(Context context,
            String title, String message,
            DialogInterface.OnClickListener listener) {
        AlertDialog alert = new AlertDialog.Builder(context).create();
        alert.setTitle(title);//  w  ww  .  ja va 2s .c  o  m
        alert.setMessage(message);
        alert.setInverseBackgroundForced(true);
        alert.setCancelable(false);
        alert.setButton(AlertDialog.BUTTON_POSITIVE,
                context.getString(R.string.close), listener);
        return alert;
    }
}

Related Tutorials