Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**
     * build a alert dialog
     *
     * @param context
     * @param title
     * @param msg
     * @param ok
     * @param cancel
     * @param lOk
     * @param lCancel
     * @return
     */
    public static AlertDialog buildAlert(Context context, Integer title, Integer msg, Integer ok, Integer cancel,
            DialogInterface.OnClickListener lOk, DialogInterface.OnClickListener lCancel) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        if (title != null)
            builder.setTitle(title);
        if (msg != null)
            builder.setMessage(msg);
        if (ok != null)
            builder.setPositiveButton(ok, lOk);
        if (cancel != null)
            builder.setNegativeButton(cancel, lCancel);
        return builder.create();
    }

    /**
     * build a alert dialog
     *
     * @param context
     * @param title
     * @param msg
     * @param ok
     * @param cancel
     * @param lOk
     * @param lCancel
     * @return
     */
    public static AlertDialog buildAlert(Context context, CharSequence title, CharSequence msg, CharSequence ok,
            CharSequence cancel, DialogInterface.OnClickListener lOk, DialogInterface.OnClickListener lCancel) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        if (title != null)
            builder.setTitle(title);
        if (msg != null)
            builder.setMessage(msg);
        if (ok != null)
            builder.setPositiveButton(ok, lOk);
        if (cancel != null)
            builder.setNegativeButton(cancel, lCancel);
        return builder.create();
    }
}