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:com.TakeTaxi.jy.OnrouteScreen.java

public void alertdialog_canceljob() {

    String check = Query.jobQuery("clientcancel", job_id, 0, driver_id);
    if (check.equals("done")) {
        AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
        dcancelbuilder.setMessage("Job has been cancelled.\n");
        dcancelbuilder.setButton("Ok", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {

                Intent openStart = new Intent("com.TakeTaxi.jy.TakeTaxiActivity");
                startActivity(openStart);

            }/*ww  w  .  j  av a 2s  .  com*/
        });
        dcancelbuilder.show();
    } else {
        Toast.makeText(getBaseContext(), "Could not connect to server.\nPlease try again.", Toast.LENGTH_SHORT)
                .show();
    }

}

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

/**
 * Add new entry based on input/*  w w  w .j a  v a2s .  c  o  m*/
 *
 * @param input
 */
private void addEntry(String hostname, String ip) {
    if (hostname != null) {
        if (org.adawaycn.util.RegexUtils.isValidHostname(hostname)) {
            if (org.adawaycn.util.RegexUtils.isValidIP(ip)) {
                org.adawaycn.provider.ProviderHelper.insertRedirectionListItem(mActivity, hostname, ip);
            } else {
                AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                alertDialog.setTitle(R.string.no_ip_title);
                alertDialog.setMessage(getString(R.string.no_ip));
                alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sum) {
                        dlg.dismiss();
                    }
                });
                alertDialog.show();
            }
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java

void setupNewCalendar() {
    caldroidFragment = new CaldroidSampleCustomFragment();
    Bundle args = new Bundle();
    DateTime now = DateTime.now();// w  ww . j  a  v a2 s .co m
    args.putInt(CaldroidFragment.MONTH, now.getMonthOfYear());
    args.putInt(CaldroidFragment.YEAR, now.getYear());
    args.putBoolean(CaldroidFragment.SHOW_NAVIGATION_ARROWS, false);
    args.putBoolean(CaldroidFragment.SIX_WEEKS_IN_CALENDAR, false);
    args.putInt(CaldroidFragment.START_DAY_OF_WEEK, CaldroidFragment.MONDAY);
    args.putInt(CaldroidFragment.THEME_RESOURCE, R.style.CaldroidDefaultNoGrid);
    caldroidFragment.setArguments(args);
    FragmentTransaction t = getSupportFragmentManager().beginTransaction();
    t.replace(R.id.calendar, caldroidFragment);
    t.commit();

    final CaldroidListener listener = new CaldroidListener() {

        @Override
        public void onSelectDate(Date date, View view) {
            LocalDate d = LocalDate.fromDateFields(date);
            onDaySelected(d);
            if (bestDay != null && bestDay.first != null && bestDay.first.equals(d)) {
                //Toast.makeText(CalendarActivity.this, "Best day!", Toast.LENGTH_SHORT).show();
                AlertDialog.Builder builder = new AlertDialog.Builder(CalendarActivity.this);
                builder.setTitle(R.string.best_date_recommendation_title).setPositiveButton(
                        getString(R.string.driving_warning_gotit), new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                AlertDialog alertDialog = builder.create();
                alertDialog.setMessage(bestDayText);
                alertDialog.show();
            }
        }

        @Override
        public void onChangeMonth(int month, int year) {
            DateTime date = DateTime.now().withYear(year).withMonthOfYear(month);
            subtitle.setText(date.toString("MMMM YYYY").toUpperCase());
        }

        @Override
        public void onLongClickDate(Date date, View view) {

        }

        @Override
        public void onCaldroidViewCreated() {
            caldroidFragment.getView().findViewById(R.id.calendar_title_view).setVisibility(View.GONE);
            caldroidFragment.getMonthTitleTextView().setVisibility(View.GONE);
        }

    };

    caldroidFragment.setCaldroidListener(listener);
    this.bestDay = pickupUtils.getBestDay();
    this.bestDayText = getBestDayText();

    if (this.bestDay != null && this.bestDay.first != null) {
        //Toast.makeText(CalendarActivity.this, "Best day: " + bestDay.first.toString("dd/MM/YY"), Toast.LENGTH_SHORT).show();
        caldroidFragment.setBackgroundDrawableForDate(
                new ColorDrawable(getResources().getColor(R.color.android_green_light)),
                this.bestDay.first.toDate());
    }

    caldroidFragment.refreshView();
}

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

/**
 * Edit entry based on selection in context menu
 *
 * @param info/*from w w w  .j a  va2  s .  co 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;

    CheckBox cBox = (CheckBox) v.findViewWithTag(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_hostname_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    inputEditText.setText(cBox.getText());

    // 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.isValidHostname(input)) {
                        ProviderHelper.updateBlacklistItemHostname(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
                        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:sssemil.com.hostsaway.ui.WhitelistFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info//from  www .jav  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;

    CheckBox cBox = (CheckBox) v.findViewWithTag(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_whitelist_hostname_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    inputEditText.setText(cBox.getText());

    // 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.isValidWhitelistHostname(input)) {
                        ProviderHelper.updateWhitelistItemHostname(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
                        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.LMO.capstone.KnoWITHerbalMain.java

private void resolver() throws XmlPullParserException, IOException {
    if (!new File(Config.dbPath(getApplicationContext())).exists()) { //no DB, no Folder
        HowToUseFragment howto = new HowToUseFragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.frame_content, howto);
        ft.addToBackStack("help");
        ft.commit();//from   w  ww .  j a v  a  2 s  . co m
        if (util.isNetworkAvailable())
            util.PrepareFileForDatabase();
    } else {
        File appDir = new File(Config.externalDirectory);
        if (!appDir.exists())
            appDir.mkdir();

        FileFilter filter = new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                // TODO Auto-generated method stub
                return pathname.toString().toLowerCase(Locale.getDefault()).contains(".jpg")
                        || pathname.toString().toLowerCase(Locale.getDefault()).contains(".png")
                        || pathname.toString().toLowerCase(Locale.getDefault()).contains(".bmp")
                        || pathname.toString().toLowerCase(Locale.getDefault()).contains(".gif")
                        || pathname.toString().toLowerCase(Locale.getDefault()).contains(".jpeg");
            }
        };
        File[] files = appDir.listFiles(filter);
        dbHelper = new DatabaseHelper(this);
        int imageEntryCount = Queries.getImageEntryCount(sqliteDB, dbHelper);

        if (files.length == 1 || (files.length + 1) < imageEntryCount) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            AlertDialog dialog = builder.create();
            dialog.setTitle("Oops!");
            dialog.setMessage("It seems your data is invalid!\nRe-download now?");
            dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    if (util.isNetworkAvailable())
                        Queries.truncateDatabase(sqliteDB, dbHelper, getApplicationContext());
                    util.PrepareFileForDatabase();
                }
            });
            dialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Maybe later", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    dialog.dismiss();
                }
            });
            dialog.show();
        }
    }
}

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

/**
 * Edit entry based on selection in context menu
 * //from   w w w.j a  v a  2s  .  co  m
 * @param info
 */
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;

    CheckBox cBox = (CheckBox) v.findViewWithTag(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_hostname_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    inputEditText.setText(cBox.getText());

    // 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.isValidHostname(input)) {
                        ProviderHelper.updateBlacklistItemHostname(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(org.adaway.R.string.no_hostname));
                        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.WhitelistFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info//from  w  ww. j a v  a2 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;

    CheckBox cBox = (CheckBox) v.findViewWithTag(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_whitelist_hostname_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    inputEditText.setText(cBox.getText());

    // 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.isValidWhitelistHostname(input)) {
                        ProviderHelper.updateWhitelistItemHostname(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(org.adaway.R.string.no_hostname));
                        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.WhitelistFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info//from w  ww . ja  va 2s.  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;

    CheckBox cBox = (CheckBox) v.findViewWithTag(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_whitelist_hostname_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    inputEditText.setText(cBox.getText());

    // 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.isValidWhitelistHostname(input)) {
                        ProviderHelper.updateWhitelistItemHostname(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(R.string.no_hostname));
                        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.BlacklistFragment.java

/**
 * Edit entry based on selection in context menu
 * //ww w.  j  a  v  a 2s .  c  o m
 * @param info
 */
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;

    CheckBox cBox = (CheckBox) v.findViewWithTag(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_hostname_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    inputEditText.setText(cBox.getText());

    // 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 (org.adawaycn.util.RegexUtils.isValidHostname(input)) {
                        org.adawaycn.provider.ProviderHelper.updateBlacklistItemHostname(mActivity,
                                mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(R.string.no_hostname));
                        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();
}