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:pl.bcichecki.rms.client.android.dialogs.EventDetailsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (event == null) {
        throw new IllegalStateException("Event has not been set!");
    }/*from w  w  w  . jav  a2  s  .c om*/
    if (eventsRestClient == null) {
        throw new IllegalStateException("EventsRestClient has not been set!");
    }
    if (eventsListAdapter == null) {
        throw new IllegalStateException("EventsListAdapter has not been set!");
    }

    context = getActivity();

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
    dialogBuilder.setTitle(getString(R.string.dialog_event_details_title, event.getTitle()));
    dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_event_details, null));

    final boolean isUserSignedUp = event.isUserSignedUp(UserProfileHolder.getUserProfile());
    dialogBuilder.setNeutralButton(
            isUserSignedUp ? R.string.dialog_event_details_sign_out : R.string.dialog_event_details_sign_up,
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    signUp(!isUserSignedUp);
                }
            });

    dialogBuilder.setPositiveButton(R.string.general_close, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Nothing to do...
        }
    });

    AlertDialog dialog = dialogBuilder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {

            TextView descriptionTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_event_details_description_text);
            TextView devicesTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_event_details_devices_text);
            TextView endsTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_event_details_ends_text);
            TextView participantsTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_event_details_participants_text);
            TextView startsTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_event_details_starts_text);
            TextView titleTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_event_details_title_text);
            TextView eventTypeTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_event_details_type_text);

            titleTextView.setText(event.getTitle());
            startsTextView
                    .setText(AppUtils.getFormattedDateAsString(event.getStartDate(), Locale.getDefault()));
            endsTextView.setText(AppUtils.getFormattedDateAsString(event.getEndDate(), Locale.getDefault()));
            descriptionTextView.setText(event.getDescription());

            if (event.getType().equals(EventType.MEETING)) {
                eventTypeTextView.setText(R.string.dialog_event_details_type_meeting);
            }
            if (event.getType().equals(EventType.INTERVIEW)) {
                eventTypeTextView.setText(R.string.dialog_event_details_type_interview);
            }

            if (event.getParticipants() != null && event.getParticipants().size() > 0) {
                StringBuilder participants = new StringBuilder();
                int counter = 1;
                for (Iterator<User> participantIterator = event.getParticipants()
                        .iterator(); participantIterator.hasNext();) {
                    User participant = participantIterator.next();
                    participants.append(counter).append(". ");
                    if (participant.getAddress() != null && participant.getAddress().getFirstName() != null
                            && participant.getAddress().getLastName() != null) {
                        participants.append(participant.getAddress().getFirstName()).append(" ")
                                .append(participant.getAddress().getLastName());
                    } else {
                        participants.append(participant.getUsername());
                    }
                    if (participantIterator.hasNext()) {
                        participants.append("\n");
                        counter++;
                    }
                }
                participantsTextView.setText(participants);
            } else {
                participantsTextView.setText(R.string.dialog_event_details_no_participants);
            }

            if (event.getDevices() != null && event.getDevices().size() > 0) {
                StringBuilder devices = new StringBuilder();
                int counter = 1;
                for (Iterator<Device> deviceIterator = event.getDevices().iterator(); deviceIterator
                        .hasNext();) {
                    Device device = deviceIterator.next();
                    devices.append(counter).append(". ");
                    devices.append(device.getName());
                    if (deviceIterator.hasNext()) {
                        devices.append("\n");
                        counter++;
                    }
                }
                devicesTextView.setText(devices);
            } else {
                devicesTextView.setText(R.string.dialog_event_details_no_devices);
            }

        }
    });

    return dialog;
}

From source file:com.googlecode.android_scripting.facade.ui.AlertDialogTask.java

@Override
public void onCreate() {
    super.onCreate();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    if (mTitle != null) {
        builder.setTitle(mTitle);
    }//from  ww  w. j a v a 2s.c  o  m
    // Can't display both a message and items. We'll elect to show the items instead.
    if (mMessage != null && mItems.isEmpty()) {
        builder.setMessage(mMessage);
    }
    switch (mInputType) {
    // Add single choice menu items to dialog.
    case SINGLE_CHOICE:
        builder.setSingleChoiceItems(getItemsAsCharSequenceArray(), mSelectedItems.iterator().next(),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        mSelectedItems.clear();
                        mSelectedItems.add(item);
                    }
                });
        break;
    // Add multiple choice items to the dialog.
    case MULTI_CHOICE:
        boolean[] selectedItems = new boolean[mItems.size()];
        for (int i : mSelectedItems) {
            selectedItems[i] = true;
        }
        builder.setMultiChoiceItems(getItemsAsCharSequenceArray(), selectedItems,
                new DialogInterface.OnMultiChoiceClickListener() {
                    public void onClick(DialogInterface dialog, int item, boolean isChecked) {
                        if (isChecked) {
                            mSelectedItems.add(item);
                        } else {
                            mSelectedItems.remove(item);
                        }
                    }
                });
        break;
    // Add standard, menu-like, items to dialog.
    case MENU:
        builder.setItems(getItemsAsCharSequenceArray(), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                Map<String, Integer> result = new HashMap<String, Integer>();
                result.put("item", item);
                dismissDialog();
                setResult(result);
            }
        });
        break;
    case PLAIN_TEXT:
        mEditText = new EditText(getActivity());
        if (mDefaultText != null) {
            mEditText.setText(mDefaultText);
        }
        mEditText.setInputType(mEditInputType);
        builder.setView(mEditText);
        break;
    case PASSWORD:
        mEditText = new EditText(getActivity());
        mEditText.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
        mEditText.setTransformationMethod(new PasswordTransformationMethod());
        builder.setView(mEditText);
        break;
    default:
        // No input type specified.
    }
    configureButtons(builder, getActivity());
    addOnCancelListener(builder, getActivity());
    mDialog = builder.show();
    mShowLatch.countDown();
}

From source file:com.phonegap.Notification.java

/**
 * Builds and shows a native Android alert with given Strings
 * @param message       The message the alert should display
 * @param title       The title of the alert
 * @param buttonLabel    The label of the button 
 * @param callbackId   The callback id//from  ww  w.j  a va  2 s.com
 */
public synchronized void alert(final String message, final String title, final String buttonLabel,
        final String callbackId) {

    final PhonegapActivity ctx = this.ctx;
    final Notification notification = this;

    Runnable runnable = new Runnable() {
        public void run() {

            AlertDialog.Builder dlg = new AlertDialog.Builder(ctx);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);
            dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    notification.success(new PluginResult(PluginResult.Status.OK, 0), callbackId);
                }
            });
            dlg.create();
            dlg.show();
        };
    };
    this.ctx.runOnUiThread(runnable);
}

From source file:net.internetTelephone.program.project.init.create.ProjectCreateFragment.java

private void showWarningDialog() {
    LayoutInflater factory = LayoutInflater.from(getActivity());
    final View textEntryView = factory.inflate(R.layout.init_dialog_text_entry2, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    AlertDialog dialog = builder.setTitle("??").setView(textEntryView)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override//w  ww . j  av a2 s.  c  o  m
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).show();
}

From source file:net.hockeyapp.android.internal.CheckUpdateTask.java

private void showDialog(final JSONArray updateInfo) {
    if (getCachingEnabled()) {
        VersionCache.setVersionInfo(activity, updateInfo.toString());
    }//from w  w w  .j av  a 2  s .c  o m

    if ((activity == null) || (activity.isFinishing())) {
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(Strings.get(listener, Strings.UPDATE_DIALOG_TITLE_ID));

    if (!mandatory) {
        builder.setMessage(Strings.get(listener, Strings.UPDATE_DIALOG_MESSAGE_ID));

        builder.setNegativeButton(Strings.get(listener, Strings.UPDATE_DIALOG_NEGATIVE_BUTTON_ID),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        cleanUp();
                    }
                });

        builder.setPositiveButton(Strings.get(listener, Strings.UPDATE_DIALOG_POSITIVE_BUTTON_ID),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (getCachingEnabled()) {
                            VersionCache.setVersionInfo(activity, "[]");
                        }

                        if ((UpdateManager.fragmentsSupported()) && (UpdateManager.runsOnTablet(activity))) {
                            showUpdateFragment(updateInfo);
                        } else {
                            startUpdateIntent(updateInfo, false);
                        }
                    }
                });

        builder.create().show();
    } else {
        Toast.makeText(activity, Strings.get(listener, Strings.UPDATE_MANDATORY_TOAST_ID), Toast.LENGTH_LONG)
                .show();
        startUpdateIntent(updateInfo, true);
    }
}

From source file:pl.bcichecki.rms.client.android.activities.NewMessageActivity.java

private void createRecipentsListDialog() {
    usernames = new String[users.size()];
    chosenUsers = new boolean[users.size()];

    for (int i = 0; i < users.size(); i++) {
        usernames[i] = users.get(i).getUsername();
    }/* w  w w  . ja v a  2 s .  c  om*/

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
    dialogBuilder.setTitle(R.string.activity_new_message_pick_recipents);
    dialogBuilder.setMultiChoiceItems(usernames, chosenUsers, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                pickedUsers.add(users.get(which));
                recipentsEditText.setError(null);
            } else {
                pickedUsers.remove(users.get(which));
            }
            updateRecipentsEditText();
        }
    });
    dialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Nothing to do...
        }
    });

    recipentsListDialog = dialogBuilder.create();
}

From source file:com.citrus.sdk.fragments.SavedOptions.java

private void showPopup() {
    final String email = OneClicksignup.getDefaultGmail(getActivity());

    final BooleanTask ontask = new BooleanTask() {
        @Override/* w  w w .  j a va 2s.c om*/
        public void ontaskComplete(boolean result) {
            if (result) {
                Toast.makeText(getActivity().getApplicationContext(), "An Email has been sent to you",
                        Toast.LENGTH_SHORT).show();
            }
        }
    };

    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setTitle("Reset Password?");

    builder.setMessage("An email will be sent to " + email);

    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            new ResetPassword(getActivity(), email, ontask).execute();
        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

        }
    });

    builder.create();

    builder.show();
}

From source file:com.sourcey.materiallogindemo.PostItemActivity.java

private void DialogRequest(final String map_id, final String passenger) {
    View dialogBoxView = View.inflate(this, R.layout.dialog_request, null);
    final Button btnMap = (Button) dialogBoxView.findViewById(R.id.btnMap);
    final Button btnRequest = (Button) dialogBoxView.findViewById(R.id.btnRequest);

    btnMap.setOnClickListener(new View.OnClickListener() {
        @Override//from  www .  j  a va 2s .  c om
        public void onClick(View v) {
            DialogMap();
        }
    });
    btnRequest.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if ("CAR".equals(type)) {
                saveRequest(map_id, user_id);
            } else if ("NOCAR".equals(type)) {
                saveRequest(map_id, passenger);
            } else {
                MessageDialog("!!");
            }
        }
    });
    /* String url = getString(R.string.url_map)+"index.php?poinFrom="+txtStart.getText().toString().trim()+"&poinTo="+txtEnd.getText().toString().trim();
            
     map.getSettings().setLoadsImagesAutomatically(true);
     map.getSettings().setJavaScriptEnabled(true);
     map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
     map.loadUrl(url);*/

    AlertDialog.Builder builderInOut = new AlertDialog.Builder(this);
    builderInOut.setTitle("?");
    builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false)
            .setPositiveButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).show();
}

From source file:eu.codeplumbers.cosi.wizards.firstrun.ConnectFragment.java

private void showGiveDevicePasswordDialog() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("Register your device");
    alertDialog.setMessage("Your device is already registered\n Please type your device token");

    final EditText input = new EditText(getActivity());

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    input.setLayoutParams(lp);//w  w w . j  a  va 2 s.  c  om
    alertDialog.setView(input);

    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String password = input.getText().toString();

            if (!password.isEmpty()) {
                final JSONObject permissionJson = new JSONObject();
                final JSONObject desc = new JSONObject();
                try {
                    Device device = new Device();
                    device.setUrl(mUrl.getText().toString());
                    device.setLogin(mDeviceName.getText().toString());
                    device.setPassword(password);

                    desc.put("description", "sync all my cozy data");
                    permissionJson.put("All", desc);

                    device.setPermissions(permissionJson.toString());
                    device.setFirstSyncDone(false);
                    device.setSyncCalls(false);
                    device.setSyncContacts(false);
                    device.setSyncFiles(false);
                    device.setSyncNotes(false);

                    device.save();

                    onRegisterSuccess(device);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                input.setError("Your device token can not be empty!");
            }
        }
    });
    alertDialog.show();
}

From source file:net.coding.program.project.init.create.ProjectCreateFragment.java

private void showWarningDialog() {
    LayoutInflater factory = LayoutInflater.from(getActivity());
    final View textEntryView = factory.inflate(R.layout.init_dialog_text_entry2, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    AlertDialog dialog = builder.setTitle("??").setView(textEntryView)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override//from   w ww  .  j  a va2s. c o  m
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).show();
    CustomDialog.dialogTitleLineColor(getActivity(), dialog);
}