Android Dialog Create makeSimpleDialog(String text)

Here you can find the source of makeSimpleDialog(String text)

Description

make Simple Dialog

License

Apache License

Declaration

public Dialog makeSimpleDialog(String text) 

Method Source Code

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

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;

import android.util.Log;

public class Main {
    static final String TAG = "GameHelper";
    /**//ww w  . j  av a 2s.  c  om
     * The Activity we are bound to. We need to keep a reference to the Activity
     * because some games methods require an Activity (a Context won't do). We
     * are careful not to leak these references: we release them on onStop().
     */
    Activity mActivity = null;

    static Dialog makeSimpleDialog(Activity activity, String text) {
        return (new AlertDialog.Builder(activity)).setMessage(text)
                .setNeutralButton(android.R.string.ok, null).create();
    }

    static Dialog makeSimpleDialog(Activity activity, String title,
            String text) {
        return (new AlertDialog.Builder(activity)).setMessage(text)
                .setTitle(title)
                .setNeutralButton(android.R.string.ok, null).create();
    }

    public Dialog makeSimpleDialog(String text) {
        if (mActivity == null) {
            logError("*** makeSimpleDialog failed: no current Activity!");
            return null;
        }
        return makeSimpleDialog(mActivity, text);
    }

    public Dialog makeSimpleDialog(String title, String text) {
        if (mActivity == null) {
            logError("*** makeSimpleDialog failed: no current Activity!");
            return null;
        }
        return makeSimpleDialog(mActivity, title, text);
    }

    void logError(String message) {
        Log.e(TAG, "*** GameHelper ERROR: " + message);
    }
}

Related

  1. setDialogPositiveButtonHolder( DialogInterface dialog, Boolean flag)
  2. makeSimpleDialog(Activity activity, String text)
  3. makeSimpleDialog(Activity activity, String title, String text)
  4. makeSimpleDialog(String title, String text)
  5. getDialogFinishListener( final Activity activity)