List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:br.ufg.inf.es.fs.contpatri.mobile.webservice.Autenticar.java
/** * Mtodo que exibe um <code>Dialog</code> caso haja erro no login do * usurio no aplicativo./*from w w w .j a v a 2 s.com*/ * * @param contexto * <code>Context</code> necessrio para criar e exibir a caixa de * dilogo. * @param mensagem * mensagem de erro que ser exibida na <code>Dialog</code> para * informar o motivo de a aplicao no realizar o login * corretamente */ public static void mostrarDialogo(final Context contexto, final String mensagem) { AlertDialog.Builder builder; builder = new AlertDialog.Builder(contexto); builder.setTitle("Erro"); builder.setMessage(mensagem); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); final AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(true); dialog.show(); }
From source file:com.bt.download.android.gui.util.UIUtils.java
public static void showYesNoDialog(Context context, String message, int titleId, OnClickListener positiveListener, OnClickListener negativeListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message).setTitle(titleId).setCancelable(false) .setPositiveButton(android.R.string.yes, positiveListener) .setNegativeButton(android.R.string.no, negativeListener); builder.create().show(); }
From source file:Main.java
public static AlertDialog createAlert(String title, String message, Context context) { // Make an AlertDialog builder AlertDialog.Builder builder1 = new AlertDialog.Builder(context); //TODO: extract string // Set title// w w w .ja va 2 s . co m builder1.setTitle(title); // Set message builder1.setMessage(message); // Set cancelable builder1.setCancelable(true); // Build a new neutral button dialog builder1.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { // On click of the neutral button public void onClick(DialogInterface dialog, int id) { // Cancel the dialog dialog.cancel(); } }); // Create the AlertDialog AlertDialog alert11 = builder1.create(); return alert11; }
From source file:com.bt.download.android.gui.util.UIUtils.java
public static void showYesNoDialog(Context context, int iconId, String message, int titleId, OnClickListener positiveListener, OnClickListener negativeListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setIcon(iconId).setMessage(message).setTitle(titleId).setCancelable(false) .setPositiveButton(android.R.string.yes, positiveListener) .setNegativeButton(android.R.string.no, negativeListener); builder.create().show(); }
From source file:com.bt.download.android.gui.util.UIUtils.java
/** * //ww w . j av a 2 s .c om * @param context * @param messageId * @param titleId * @param positiveListener * @param negativeListener */ public static Dialog showYesNoDialog(Context context, int messageId, int titleId, OnClickListener positiveListener, OnClickListener negativeListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(messageId).setTitle(titleId).setCancelable(false) .setPositiveButton(android.R.string.yes, positiveListener) .setNegativeButton(android.R.string.no, negativeListener); Dialog dialog = builder.create(); dialog.show(); return dialog; }
From source file:com.bt.download.android.gui.util.UIUtils.java
public static void showYesNoDialog(Context context, int iconId, int messageId, int titleId, OnClickListener positiveListener, OnClickListener negativeListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setIcon(iconId).setMessage(messageId).setTitle(titleId).setCancelable(false) .setPositiveButton(android.R.string.yes, positiveListener) .setNegativeButton(android.R.string.no, negativeListener); builder.create().show(); }
From source file:com.spoiledmilk.cykelsuperstier.navigation.SMRouteNavigationActivity.java
public static void showRouteNoBreakDialog(final Context context, AlertDialog dialog) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(CykelsuperstierApplication.getString("no_route")); builder.setMessage(CykelsuperstierApplication.getString("cannot_broken")); builder.setPositiveButton("OK", new OnClickListener() { @Override/* w w w . j a v a2 s . c o m*/ public void onClick(DialogInterface dialog, int arg1) { dialog.dismiss(); } }); dialog = builder.create(); dialog.setCancelable(false); dialog.show(); }
From source file:Main.java
public static void DisplayAlertOKCancel(final Context context, final String title, final String message) { retValue = -1;/*from w ww . ja va 2 s. c o m*/ final Activity activity = (Activity) context; activity.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message); builder.setTitle(title); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { retValue = 1; alert = null; } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { retValue = 0; alert = null; } }); alert = builder.create(); alert.show(); } }); }
From source file:Main.java
public static void alertTurnOnGPS(final Context mContext) { final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage("Do you want to enable GPS?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { mContext.startActivity( new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }/*from w w w . jav a 2s .c o m*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:org.gplvote.signdoc.MainActivity.java
public static void error(String text, final Activity activity, final boolean parent_exit) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.title_error).setIcon(R.drawable.cancel_icon).setMessage(text).setCancelable(false) .setNegativeButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();// w ww .ja v a2 s .c o m if (parent_exit) { activity.finish(); } } }); AlertDialog alert = builder.create(); alert.show(); }