Example usage for android.app AlertDialog setMessage

List of usage examples for android.app AlertDialog setMessage

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:sssemil.com.hostsaway.ui.HostsSourcesFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info// ww  w . j  a  v a2 s .com
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView urlTextView = (TextView) v.findViewWithTag("url_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_url_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_url);
    // set text from list
    inputEditText.setText(urlTextView.getText());
    inputEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    // move cursor to end of EditText
    Editable inputEditContent = inputEditText.getText();
    inputEditText.setSelection(inputEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String input = inputEditText.getText().toString();

                    if (RegexUtils.isValidUrl(input)) {
                        // update in db
                        ProviderHelper.updateHostsSourceUrl(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_url_title);
                        alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_url));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.adaway.ui.HostsSourcesFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info/*w w  w  .  j  a v  a 2  s  .  c o m*/
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView urlTextView = (TextView) v.findViewWithTag("url_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_url_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_url);
    // set text from list
    inputEditText.setText(urlTextView.getText());
    inputEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    // move cursor to end of EditText
    Editable inputEditContent = inputEditText.getText();
    inputEditText.setSelection(inputEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String input = inputEditText.getText().toString();

                    if (RegexUtils.isValidUrl(input)) {
                        // update in db
                        ProviderHelper.updateHostsSourceUrl(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_url_title);
                        alertDialog.setMessage(getString(org.adaway.R.string.no_url));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.adawaycn.ui.HostsSourcesFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info//  w w  w  .java 2  s.  c  om
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView urlTextView = (TextView) v.findViewWithTag("url_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_url_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_url);
    // set text from list
    inputEditText.setText(urlTextView.getText());
    inputEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    // move cursor to end of EditText
    Editable inputEditContent = inputEditText.getText();
    inputEditText.setSelection(inputEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String input = inputEditText.getText().toString();

                    if (RegexUtils.isValidUrl(input)) {
                        // update in db
                        ProviderHelper.updateHostsSourceUrl(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_url_title);
                        alertDialog.setMessage(getString(R.string.no_url));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.aknowledge.v1.automation.RemoteActivity.java

public void onDevicesLoaded(String result) {
    Log.d("RemoteActivity", "devices loaded: " + result);

    if (dialog != null && dialog.isShowing()) {
        dialog.dismiss();/*from  w ww .j a v  a 2  s.c  o  m*/
    }
    if (result != null) {
        parseMyDevices(result);
        createRemotePanel();
    } else {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("Problems with your server info.");
        alertDialog.setMessage("You should check your settings and try again.");
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        // Set the Icon for the Dialog
        alertDialog.show();

    }

}

From source file:nl.nikhef.eduroam.WiFiEduroam.java

private void alert(String title, String message) {
    AlertDialog alertBox = new AlertDialog.Builder(this).create();
    alertBox.setTitle(title);/*from  w  w  w  . ja  v  a 2 s .  c  om*/
    alertBox.setMessage(message);
    alertBox.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            onActivityResult(2, RESULT_OK, null);
        }
    });
    alertBox.show();
}

From source file:me.panpf.tool4a.app.MessageDialogFragment.java

/**
 * ?//  w  ww  .  j a v  a2s.  com
 *
 * @param messageDialog ?
 */
private void applyParams(AlertDialog messageDialog) {
    if (builder == null)
        throw new IllegalArgumentException("builder null ?setBuilder()Builder");
    if (builder.message == null)
        throw new IllegalArgumentException("Builder.setMessage()?");

    messageDialog.setTitle(builder.title);
    messageDialog.setMessage(builder.message);
    if (builder.confirmButtonName != null) {
        messageDialog.setButton(AlertDialog.BUTTON_POSITIVE, builder.confirmButtonName,
                builder.confirmButtonClickListener);
    }
    if (builder.cancelButtonName != null) {
        messageDialog.setButton(AlertDialog.BUTTON_NEGATIVE, builder.cancelButtonName,
                builder.cancelButtonClickListener);
    }
    if (builder.neutralButtonName != null) {
        messageDialog.setButton(AlertDialog.BUTTON_NEUTRAL, builder.neutralButtonName,
                builder.neutralButtonClickListener);
    }
    messageDialog.setOnKeyListener(builder.onKeyListener);
    messageDialog.setOnShowListener(builder.onShowListener);
    setCancelable(builder.cancelable);
}

From source file:org.odk.collect.android.activities.FormHierarchyActivity.java

/**
 * Creates and displays dialog with the given errorMsg.
 *///from   www  . j a  va  2  s . com
private void createErrorDialog(String errorMsg) {
    Collect.getInstance().getActivityLogger().logInstanceAction(this, "createErrorDialog", "show.");

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();

    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertDialog.setTitle(getString(R.string.error_occured));
    alertDialog.setMessage(errorMsg);
    DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
            case DialogInterface.BUTTON_POSITIVE:
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "createErrorDialog", "OK");
                FormController formController = Collect.getInstance().getFormController();
                formController.jumpToIndex(currentIndex);
                break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(getString(R.string.ok), errorListener);
    alertDialog.show();
}

From source file:ti.modules.titanium.ui.widget.TiUIDialog.java

@Override
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) {
    Log.d(TAG, "Property: " + key + " old: " + oldValue + " new: " + newValue, Log.DEBUG_MODE);

    AlertDialog dialog = dialogWrapper.getDialog();
    if (key.equals(TiC.PROPERTY_TITLE)) {
        if (dialog != null) {
            dialog.setTitle((String) newValue);
        }/*from   www. j  av a 2 s  .  c o  m*/
    } else if (key.equals(TiC.PROPERTY_MESSAGE)) {
        if (dialog != null) {
            dialog.setMessage((String) newValue);
        }
    } else if (key.equals(TiC.PROPERTY_BUTTON_NAMES)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
        processButtons(TiConvert.toStringArray((Object[]) newValue));
    } else if (key.equals(TiC.PROPERTY_OK) && !proxy.hasProperty(TiC.PROPERTY_BUTTON_NAMES)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
        processButtons(new String[] { TiConvert.toString(newValue) });
    } else if (key.equals(TiC.PROPERTY_OPTIONS)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }

        getBuilder().setView(null);
        int selectedIndex = -1;
        if (proxy.hasProperty(TiC.PROPERTY_SELECTED_INDEX)) {
            selectedIndex = TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_SELECTED_INDEX));
        }
        processOptions(TiConvert.toStringArray((Object[]) newValue), selectedIndex);
    } else if (key.equals(TiC.PROPERTY_SELECTED_INDEX)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }

        getBuilder().setView(null);
        if (proxy.hasProperty(TiC.PROPERTY_OPTIONS)) {
            processOptions(TiConvert.toStringArray((Object[]) proxy.getProperty(TiC.PROPERTY_OPTIONS)),
                    TiConvert.toInt(newValue));

        }
    } else if (key.equals(TiC.PROPERTY_ANDROID_VIEW)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
        if (newValue != null) {
            processView((TiViewProxy) newValue);
        } else {
            proxy.setProperty(TiC.PROPERTY_ANDROID_VIEW, null);
        }
    } else if (key.equals(TiC.PROPERTY_PERSISTENT) && newValue != null) {
        dialogWrapper.setPersistent(TiConvert.toBoolean(newValue));
    } else if (key.indexOf("accessibility") == 0) {
        if (dialog != null) {
            ListView listView = dialog.getListView();
            if (listView != null) {
                if (key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) {
                    int importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
                    if (newValue != null && TiConvert.toBoolean(newValue)) {
                        importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO;
                    }
                    ViewCompat.setImportantForAccessibility(listView, importance);
                } else {
                    listView.setContentDescription(composeContentDescription());
                }
            }
        }
    } else {
        super.propertyChanged(key, oldValue, newValue, proxy);
    }
}

From source file:cm.aptoide.pt.Aptoide.java

private void downloadServ(String srv) {
    try {//from  ww w .j  av  a  2s  .c om
        keepScreenOn.acquire();

        BufferedInputStream getit = new BufferedInputStream(new URL(srv).openStream());

        File file_teste = new File(TMP_SRV_FILE);
        if (file_teste.exists())
            file_teste.delete();

        FileOutputStream saveit = new FileOutputStream(TMP_SRV_FILE);
        BufferedOutputStream bout = new BufferedOutputStream(saveit, 1024);
        byte data[] = new byte[1024];

        int readed = getit.read(data, 0, 1024);
        while (readed != -1) {
            bout.write(data, 0, readed);
            readed = getit.read(data, 0, 1024);
        }

        keepScreenOn.release();

        bout.close();
        getit.close();
        saveit.close();
    } catch (Exception e) {
        AlertDialog p = new AlertDialog.Builder(this).create();
        p.setTitle(getText(R.string.top_error));
        p.setMessage(getText(R.string.aptoide_error));
        p.setButton(getText(R.string.btn_ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        p.show();
    }
}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

@Override
protected void onCreate(Bundle arg0) {
    // TODO Auto-generated method stub
    super.onCreate(arg0);
    Bundle extras = getIntent().getExtras();
    job_id = extras.getString("job_id");
    tempLat = extras.getInt("tempLat");
    tempLongi = extras.getInt("tempLongi");

    try {/*w  w w . j a  v  a 2  s  . c o m*/
        driver_id = Query.getJobInfo(job_id).getString("driver_id");
    } catch (JSONException e) {
    }

    clientpng = getResources().getDrawable(R.drawable.greendot);
    taxipng = getResources().getDrawable(R.drawable.cabs);

    setContentView(R.layout.onroute);
    map = (MapView) findViewById(R.id.mvOnroute);
    map.setBuiltInZoomControls(true);
    overlayList = map.getOverlays();

    mySubmittedPosition = new GeoPoint(tempLat, tempLongi);
    map.getController().setCenter(mySubmittedPosition);
    map.getController().setZoom(17);
    localpos();

    TextView tvTaxiLicense = (TextView) findViewById(R.id.tvTaxiLicense);
    //TextView tvTaxiType = (TextView) findViewById(R.id.tvTaxiType);

    tvTaxiLicense.setText(Query.getDriverDetail("license", driver_id));
    //tvTaxiType.setText(job_id);

    tvORTop = (TextView) findViewById(R.id.tvORTop);
    tvORTop.setText(Query.getDriverDetail("name", driver_id) + " is en route");
    getDriverPosition(driver_id);

    handlerboolean = true;

    handler.postDelayed(r, 5000);

    // ///////////////////////////// CANCEL BUTTON ///////////////
    // ////////////////////////////////////////////////////////////
    Button cancel = (Button) findViewById(R.id.bOnrouteCancelCall);
    cancel.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            try {

                JSONObject json = Query.getJobInfo(job_id);

                int starttime = json.getInt("datetime");

                // ////////////////// CANCEL BUTTON - REPORT NO SHOW /////
                if (starttime + 300 <= Query.getServerTime()) {
                    handlerboolean = false;
                    handler.removeCallbacks(r);

                    AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
                    dcancelbuilder
                            .setMessage("Job has been cancelled.\nWould you like to report a driver no-show?.");

                    // ///////// NO button - normal client cancel ////////
                    button_cancelJob(dcancelbuilder);
                    // ///////// YES button - report driver NO SHOW ////////
                    button_cancelJob_driverNoShow(dcancelbuilder);

                    dcancelbuilder.show();

                } else {
                    handlerboolean = false;
                    handler.removeCallbacks(r);

                    alertdialog_canceljob();
                }

            } catch (JSONException e) {
            }

        }
    });
}