Example usage for android.app AlertDialog.Builder setTitle

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

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:com.jdom.get.stuff.done.android.AndroidApplicationContextFactory.java

public void displayCollectionOfItemsAsRadioButtonGroup(String message, Collection<String> collection,
        String initialSelection, final RunnableWithResults<String> callback) {
    final String[] array = collection.toArray(new String[collection.size()]);
    int selectedItemIndex = -1;
    if (initialSelection != null) {
        for (int i = 0; i < array.length; i++) {
            if (array[i].equals(initialSelection)) {
                selectedItemIndex = i;/*from   www.  ja  v a  2 s.c om*/
            }
        }
    }

    final List<String> selectedItems = new ArrayList<String>();
    if (initialSelection != null) {
        selectedItems.add(initialSelection);
    }

    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(activity,
            android.R.layout.simple_list_item_single_choice, array);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    if (!StringUtils.isEmpty(message)) {
        builder.setTitle(message);
    }

    builder.setPositiveButton(OK_BUTTON_TEXT, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (!selectedItems.isEmpty()) {
                callback.callback(selectedItems.iterator().next());
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    }).setSingleChoiceItems(arrayAdapter, selectedItemIndex, new OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            String value = array[arg1];
            selectedItems.clear();
            selectedItems.add(value);
        }
    }).show();
}

From source file:com.librelio.activity.MainMagazineActivity.java

private Dialog createDialog(int titleId, int messageId) {
    String helpUrl = replaceLanguageAndRegion(getString(R.string.help_url));
    final Uri helpUri = Uri.parse(helpUrl);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(titleId).setIcon(android.R.drawable.stat_sys_warning).setMessage(messageId)
            .setCancelable(false).setPositiveButton(android.R.string.ok, null)
            .setNegativeButton(R.string.learn_more, new DialogInterface.OnClickListener() {
                @Override/*from   www.j  a v  a  2  s .co  m*/
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, helpUri);
                    startActivity(intent);
                }
            });
    return builder.create();
}

From source file:com.mendhak.gpslogger.common.PrefsIO.java

private void ReAskFileName() {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.FileExists);
    builder.setMessage(R.string.AskAnotherFile);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override//  ww w . j ava 2 s. co  m
        public void onClick(DialogInterface dialog, int which) {
            AskFileName();
        }
    });
    builder.show();
}

From source file:com.emobc.android.activities.generators.FormActivityGenerator.java

/**
 * Check the contents of a web address to add new data to existing 
 * app.xml file. Then, it goes to the next level.
 * @param activity//from   www .  j  ava  2 s.  com
 */
protected void processSubmit(Activity activity) {
    try {
        List<NameValuePair> parameters = createParameters();
        try {
            URL url = new URL(item.getActionUrl());

            RetreiveFileContentTask task = new RetreiveFileContentTask(parameters, true);
            task.execute(url);
            try {
                String text = task.get();

                ApplicationData.mergeAppDataFromString(activity, text);

                showNextLevel(activity, item.getNextLevel());
            } catch (InterruptedException e) {
                Log.e("FormActivityGenerator: InterruptedException: ", e.getMessage());
            } catch (ExecutionException e) {
                Log.e("FormActivityGenerator: ExecutionException: ", e.getMessage());
            }
        } catch (MalformedURLException e1) {
        }
    } catch (final RequiredFieldException e) {
        final AlertDialog.Builder dlg = new AlertDialog.Builder(activity);
        dlg.setTitle(R.string.form_level_title);
        dlg.setMessage(R.string.form_level_alert_required_fields);
        dlg.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                View view = controlsMap.get(e.getDataItem().getFieldName());
                view.requestFocus();
            }
        });
        dlg.show();
    }
}

From source file:edu.asu.bsse.vtanders.finalproject.MainActivity.java

License:asdf

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_config) {
        AlertDialog.Builder connInfoDialogBuilder = new AlertDialog.Builder(this);
        connInfoDialogBuilder.setTitle("Server Information");
        final View view = getLayoutInflater().inflate(R.layout.server_config, null);
        connInfoDialogBuilder.setView(view);
        final AlertDialog connInfoDialog = connInfoDialogBuilder.create();
        connInfoDialog.show();//from   w w w. j a  v  a2  s  .co  m
        Button apply = (Button) view.findViewById(R.id.apply_settings_button);
        apply.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText hostET = (EditText) view.findViewById(R.id.host_content);
                String host = hostET.getText().toString();

                EditText portET = (EditText) view.findViewById(R.id.port_content);
                int port = Integer.valueOf(portET.getText().toString());

                EditText nickET = (EditText) view.findViewById(R.id.nickname_content);
                String nick = nickET.getText().toString();

                Log.d("ASDF", host + " " + port + " " + nick);

                new SetupConnectionTask(host, port, nick).execute();
                connInfoDialog.dismiss();
            }
        });

        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:no.ntnu.idi.socialhitchhiking.myAccount.MyAccountPreferences.java

/**
 * Called when the button "Set Facebook privacy" is clicked. Opens an AlertDialog where the user selects a privacy setting.
 * @param view/*from   w w  w  . j av  a  2  s  . co  m*/
 */
public void btnFacebookClicked(View view) {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Set Privacy");
    builder.setSingleChoiceItems(R.array.privacy_setting, selectedPrivacy,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    selectedPrivacy = item;
                }
            });
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            switch (selectedPrivacy) {
            case 0:
                privacyPreference = Visibility.FRIENDS;
                facebookPrivacy = "Friends";
                break;
            case 1:
                privacyPreference = Visibility.FRIENDS_OF_FRIENDS;
                facebookPrivacy = "Friends of friends";
                break;
            case 2:
                privacyPreference = Visibility.PUBLIC;
                facebookPrivacy = "Public";
                break;
            default:
                break;
            }
            // Setting button text
            btnFacebook.setText(Html.fromHtml("<b align = left><big>" + "Set Facebook privacy" + "</big></b>"
                    + "<br />" + facebookPrivacy + "<br />"));

            // Writing data to SharedPreferences
            getApp().getSettings().setFacebookPrivacy(privacyPreference);
        }
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();

}

From source file:com.synvata.modules.DriverLicenseEditActivity.java

private void chooseDriverType() {
    final JSONArray list = AppSettings.driver_type_list;
    if (list == null) {
        return;/*from   w  ww.ja v a 2 s.  c  om*/
    }
    String types = ((EditText) findViewById(R.id.edt_driverlicense_car_type)).getText().toString();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    MultiChoiceID.clear();
    builder.setIcon(R.drawable.index_looks);
    builder.setTitle("Please choose");

    final String[] items = new String[list.length()];
    boolean[] checkedItems = new boolean[list.length()];
    try {
        for (int i = 0; i < list.length(); i++) {
            JSONObject item = list.getJSONObject(i);
            String code = item.getString("code");
            String name = item.getString("name");
            String years = item.getString("years");
            items[i] = String.format("%s--%s(%s)", code, name, years);
            if (types.contains(code)) {
                checkedItems[i] = true;
                MultiChoiceID.add(i);
            } else {
                checkedItems[i] = false;
            }
        }
    } catch (Exception e) {
        log(e);
    }

    builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                if (!MultiChoiceID.contains(which))
                    MultiChoiceID.add(which);
            } else {
                if (MultiChoiceID.contains(which))
                    MultiChoiceID.remove(which);
            }

        }
    });
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {

            //            String str = "";
            //                int size = MultiChoiceID.size();
            //                for (int i = 0 ;i < size; i++) {
            //                   str+= items[MultiChoiceID.get(i)] + ", ";
            //                }
            //                showDialog(str);
            changeDriverType();
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

        }
    });
    builder.show();
}

From source file:fi.mikuz.boarder.gui.internet.Settings.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internet_settings);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    @SuppressWarnings("unchecked")
    HashMap<String, String> lastSession = (HashMap<String, String>) getIntent()
            .getSerializableExtra(InternetMenu.LOGIN_KEY);

    try {//from   w  w w .j a v  a 2  s. c o m
        mUserId = lastSession.get(InternetMenu.USER_ID_KEY);
        mSessionToken = lastSession.get(InternetMenu.SESSION_TOKEN_KEY);
    } catch (NullPointerException e) {
        Toast.makeText(Settings.this, "Please login", Toast.LENGTH_LONG).show();
        Settings.this.finish();
    }

    Button changePassword = (Button) findViewById(R.id.change_password);

    changePassword.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LayoutInflater inflater = (LayoutInflater) Settings.this.getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.internet_settings_alert_change_password,
                    (ViewGroup) findViewById(R.id.alert_settings_root));

            final EditText oldPasswordInput = (EditText) layout.findViewById(R.id.oldPasswordInput);
            final EditText newPassword1Input = (EditText) layout.findViewById(R.id.newPassword1Input);
            final EditText newPassword2Input = (EditText) layout.findViewById(R.id.newPassword2Input);
            Button submitButton = (Button) layout.findViewById(R.id.submitButton);

            AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this);
            builder.setView(layout);
            builder.setTitle("Change password");

            submitButton.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    String oldPasswordText = oldPasswordInput.getText().toString();
                    String newPassword1Text = newPassword1Input.getText().toString();
                    String newPassword2Text = newPassword2Input.getText().toString();

                    if (!newPassword1Text.equals(newPassword2Text)) {
                        Toast.makeText(Settings.this, "New passwords don't match", Toast.LENGTH_LONG).show();
                    } else if (newPassword1Text.length() < 6) {
                        Toast.makeText(Settings.this, "Password length must be at least 6 characters",
                                Toast.LENGTH_LONG).show();
                    } else {
                        try {
                            mWaitDialog = new TimeoutProgressDialog(Settings.this, "Waiting for response", TAG,
                                    false);
                            HashMap<String, String> sendList = new HashMap<String, String>();
                            sendList.put(InternetMenu.PASSWORD_KEY, Security.passwordHash(newPassword1Text));
                            sendList.put(InternetMenu.OLD_PASSWORD_KEY, Security.passwordHash(oldPasswordText));
                            sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                            sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                            new ConnectionManager(Settings.this, InternetMenu.mChangePasswordURL, sendList);
                        } catch (NoSuchAlgorithmException e) {
                            mWaitDialog.dismiss();
                            String msg = "Couldn't make md5 hash";
                            Toast.makeText(Settings.this, msg, Toast.LENGTH_LONG).show();
                            Log.e(TAG, msg, e);
                        }
                    }
                }
            });

            builder.show();
        }
    });

    Button changeEmail = (Button) findViewById(R.id.change_email);

    changeEmail.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LayoutInflater inflater = (LayoutInflater) Settings.this.getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.internet_settings_alert_change_email,
                    (ViewGroup) findViewById(R.id.alert_settings_root));

            final EditText passwordInput = (EditText) layout.findViewById(R.id.passwordInput);
            final EditText newEmailInput = (EditText) layout.findViewById(R.id.newEmailInput);
            Button submitButton = (Button) layout.findViewById(R.id.submitButton);

            AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this);
            builder.setView(layout);
            builder.setTitle("Change email");

            submitButton.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    String passwordText = passwordInput.getText().toString();
                    String newEmailText = newEmailInput.getText().toString();

                    try {
                        mWaitDialog = new TimeoutProgressDialog(Settings.this, "Waiting for response", TAG,
                                false);
                        HashMap<String, String> sendList = new HashMap<String, String>();
                        sendList.put(InternetMenu.PASSWORD_KEY, Security.passwordHash(passwordText));
                        sendList.put(InternetMenu.EMAIL_KEY, newEmailText);
                        sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                        sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                        new ConnectionManager(Settings.this, InternetMenu.mChangeEmailURL, sendList);
                    } catch (NoSuchAlgorithmException e) {
                        mWaitDialog.dismiss();
                        String msg = "Couldn't make md5 hash";
                        Toast.makeText(Settings.this, msg, Toast.LENGTH_LONG).show();
                        Log.e(TAG, msg, e);
                    }
                }
            });

            builder.show();
        }
    });

}

From source file:edu.usf.cutr.opentripplanner.android.tasks.OTPGeocoding.java

protected void onCancelled(Long result) {
    if (activity.get() != null) {
        AlertDialog.Builder geocoderAlert = new AlertDialog.Builder(activity.get());
        geocoderAlert.setTitle(R.string.geocoder_results_title).setMessage(R.string.geocoder_no_results_message)
                .setCancelable(false).setPositiveButton(context.getResources().getString(android.R.string.ok),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                            }//from   ww  w .  j  a  va2 s . com
                        });

        AlertDialog alert = geocoderAlert.create();
        alert.show();
    }
    Log.e(TAG, "No geocoding processed!");
}

From source file:com.vishnuvalleru.travelweatheralertsystem.MainActivity.java

private void showAlert(String title, String message) {
    AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
    alert.setTitle(title);
    alert.setCancelable(false);/*from   w  w  w.  j  a  v a  2  s . com*/
    alert.setMessage(message);
    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    alert.show();
}