Here you can find the source of showSingleDialog(Context context, String title, String msg, boolean cancelable)
Parameter | Description |
---|---|
context | a parameter |
title | dialog title |
msg | dialog message |
cancelable | cancelable when back button clicked |
public static void showSingleDialog(Context context, String title, String msg, boolean cancelable)
//package com.java2s; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; public class Main { /**// w w w. j a v a 2s. co m * Function to create AlertDialog * * @param context * @param title * dialog title * @param msg * dialog message * @param cancelable * cancelable when back button clicked */ public static void showSingleDialog(Context context, String title, String msg, boolean cancelable) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(msg).setCancelable(cancelable).setTitle(title) .setPositiveButton("OK", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } }