get Ok Modal Alert Dialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

get Ok Modal Alert Dialog

Demo Code

/**//w  w w.ja v a  2 s  .  c o m
 * Copyright (c) {2003,2011} {openmobster@gmail.com} {individual contributors as indicated by the @authors tag}.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
//package com.java2s;

import android.content.Context;

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

public class Main {
    public static AlertDialog getOkModal(final Context currentActivity,
            String title, String message) {
        AlertDialog okModal = null;

        okModal = new AlertDialog.Builder(currentActivity).setTitle(title)
                .setMessage(message).setCancelable(false).create();
        okModal.setButton(DialogInterface.BUTTON_POSITIVE, "OK",
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int status) {
                        dialog.dismiss();
                    }
                });

        return okModal;
    }
}

Related Tutorials