Android Dialog Create makeSimpleDialog(Activity activity, String text)

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

Description

make Simple Dialog

License

Apache License

Declaration

static Dialog makeSimpleDialog(Activity activity, 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";
    /**//from www  .  j av a2 s . co m
     * 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 title, String text)
  3. makeSimpleDialog(String text)
  4. makeSimpleDialog(String title, String text)
  5. getDialogFinishListener( final Activity activity)