get Ok Attached Modal Alert Dialog With Close App - Android User Interface

Android examples for User Interface:Alert Dialog

Description

get Ok Attached Modal Alert Dialog With Close App

Demo Code

/**/*w  w w .j  a va  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.app.Activity;

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

public class Main {
    public static AlertDialog getOkAttachedModalWithCloseApp(
            final int dialogId, final Activity 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) {
                        currentActivity.dismissDialog(dialogId);
                        currentActivity.removeDialog(dialogId);
                        currentActivity.finish();
                    }
                });

        return okModal;
    }
}

Related Tutorials