Android AlertDialog Create alert(String title, String message, Context context, boolean linksClickable)

Here you can find the source of alert(String title, String message, Context context, boolean linksClickable)

Description

alert

Declaration

public static void alert(String title, String message, Context context,
            boolean linksClickable) 

Method Source Code

//package com.java2s;
import android.app.AlertDialog;

import android.content.Context;

import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;

import android.widget.TextView;

public class Main {
    public static void alert(String title, String message, Context context) {
        alert(title, message, context, false);
    }/*  w  w  w  .  j av a  2 s.com*/

    public static void alert(String title, String message, Context context,
            boolean linksClickable) {
        SpannableString spannableString = new SpannableString(message);
        if (linksClickable) {
            Linkify.addLinks(spannableString, Linkify.ALL);
        }

        AlertDialog dialog = new AlertDialog.Builder(context)
                .setTitle(title).setMessage(spannableString)
                .setPositiveButton(android.R.string.ok, null).create();
        dialog.show();
        // Make text links clickable
        if (linksClickable) {
            ((TextView) dialog.findViewById(android.R.id.message))
                    .setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
}

Related

  1. alert(Context act, int strId)
  2. showErrorDialog(Context context, int title, int message)
  3. showAlertDialog(Activity ctx, String title, String text)
  4. createAlertDialog(Context cx, String title, String message)
  5. alert(String title, String message, Context context)
  6. confirm(String title, String message, Context context, DialogInterface.OnClickListener onConfirmListener)
  7. confirm(String title, View view, Context context, DialogInterface.OnClickListener onConfirmListener)
  8. confirmBuilder(String title, Context context, DialogInterface.OnClickListener onConfirmListener)
  9. canShowAlertDialog(Context context)