Example usage for android.app AlertDialog.Builder show

List of usage examples for android.app AlertDialog.Builder show

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder show.

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.miz.functions.MizLib.java

public static void showSelectFileDialog(Context context, ArrayList<Filepath> paths,
        final Dialog.OnClickListener listener) {
    String[] items = new String[paths.size()];
    for (int i = 0; i < paths.size(); i++)
        items[i] = paths.get(i).getFilepath();

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(context.getString(R.string.selectFile));
    builder.setItems(items, listener);/*from  w  ww.j  a v a2  s .  c  om*/
    builder.show();
}

From source file:com.example.devesh.Coride.DriverRegistration.java

public void showSettingsAlert(String provider) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(DriverRegistration.this);

    alertDialog.setTitle(provider + " SETTINGS");

    alertDialog.setMessage(provider + " is not enabled! Want to go to settings menu?");

    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            DriverRegistration.this.startActivity(intent);
            dialog.cancel();/*from  w w  w  . j  a  v  a2  s .co m*/
        }
    });

    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Toast.makeText(getApplicationContext(), "Enable location to use APP", Toast.LENGTH_SHORT).show();
            dialog.cancel();

        }
    });

    alertDialog.show();
}

From source file:net.evecom.android.log.DailyLogLookActivity.java

/**
 * fh// ww w .j  a va2 s  . c  o  m
 * 
 * @param v
 */
public void logfh(View v) {

    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogLookActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            DailyLogLookActivity.this.finish();
            Intent intent = new Intent(getApplicationContext(), DailyLogListActivity.class);
            startActivity(intent);

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();

}

From source file:net.evecom.android.web.WebdbActivity.java

/**
 * /*from   ww w .  ja v  a2s  .co  m*/
 * 
 * @param v
 */
public void message_post_web_tomain(View v) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(WebdbActivity.this);
    builder1.setTitle("");
    builder1.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder1.setMessage("");
    builder1.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            if (null != webView) {
                webView.goBack();
                finish();
            }
        }
    });
    builder1.setNegativeButton("", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    builder1.show();

}

From source file:aarddict.android.ArticleViewActivity.java

private void showError(final String message) {
    runOnUiThread(new Runnable() {
        public void run() {
            currentTask = null;/*  www. jav  a  2  s  .co m*/
            setProgress(10000);
            resetTitleToCurrent();
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ArticleViewActivity.this);
            dialogBuilder.setTitle(R.string.titleError).setMessage(message)
                    .setNeutralButton(R.string.btnDismiss, new OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            if (backItems.isEmpty()) {
                                finish();
                            }
                        }
                    });
            dialogBuilder.show();
        }
    });
}

From source file:com.googlecode.android_scripting.facade.AndroidFacade.java

private String getInputFromAlertDialog(final String title, final String message, final boolean password) {
    final FutureActivityTask<String> task = new FutureActivityTask<String>() {
        @Override//from w  w w . j av a 2  s  . co  m
        public void onCreate() {
            super.onCreate();
            final EditText input = new EditText(getActivity());
            if (password) {
                input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                input.setTransformationMethod(new PasswordTransformationMethod());
            }
            AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
            alert.setTitle(title);
            alert.setMessage(message);
            alert.setView(input);
            alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                    setResult(input.getText().toString());
                    finish();
                }
            });
            alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    setResult(null);
                    finish();
                }
            });
            alert.show();
        }
    };
    mTaskQueue.execute(task);

    try {
        return task.getResult();
    } catch (Exception e) {
        Log.e("Failed to display dialog.", e);
        throw new RuntimeException(e);
    }
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

private void failDialog(int i) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());

    if (i == 2 || i == 3) {
        alertDialog.setTitle("  ? ");
        alertDialog.setMessage("? ? ");
    } else if (i == 1) {
        alertDialog.setTitle("   ");
        alertDialog.setMessage(" ? ");
    } else if (i == 4) {
        alertDialog.setTitle("  ");
        alertDialog.setMessage(" ? ");
    }//  www.  j  a  va2  s.co  m

    alertDialog.setIcon(R.drawable.fail);

    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to invoke YES event
            dialog.cancel();
        }
    });

    alertDialog.show();
}

From source file:ca.ualberta.cs.cmput301w15t04team04project.MainActivity.java

/**
 * Will be called when user clicked add Location button, it will pop a
 * dialog and let user choose the method of location which go to the
 * osmMainAcitivity//  w  ww  . ja va 2  s  . c o m
 * 
 * @param v
 *            View passed to the activity to check which button was pressed.
 */
public void goToMapAction(View v) {
    AlertDialog.Builder adb = new AlertDialog.Builder(MainActivity.this);
    if (user.getHomelocation() != null) {
        adb.setMessage("Current Home Location is " + user.getHomelocation().getLatitude()
                + user.getHomelocation().getLongitude() + "\nChoose the HomeLocation Way");

    } else {
        adb.setMessage("Choose the HomeLocation Way");
    }
    adb.setNegativeButton("GPS", new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            homeLocation = location;
            user.setHomelocation(location);
        }
    });

    adb.setPositiveButton("Map", new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(MainActivity.this, osmMainActivity.class);
            startActivity(intent);
        }
    });

    adb.setCancelable(true);
    adb.show();

}

From source file:at.jclehner.rxdroid.DrugEditFragment.java

private void showSaveChangesDialog() {
    final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
    ab.setMessage(R.string._msg_save_drug_changes);

    final DialogInterface.OnClickListener l = new DialogInterface.OnClickListener() {

        @Override/*www . j a  va 2  s  . c  o  m*/
        public void onClick(DialogInterface dialog, int which) {
            if (which == Dialog.BUTTON_POSITIVE) {
                Database.update(mWrapper.get());
                Toast.makeText(getActivity(), R.string._toast_saved, Toast.LENGTH_SHORT).show();
            }

            getActivity().finish();
        }
    };

    ab.setNegativeButton(R.string._btn_discard, l);
    ab.setPositiveButton(R.string._btn_save, l);

    ab.show();
}