Example usage for android.app AlertDialog setTitle

List of usage examples for android.app AlertDialog setTitle

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

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

/**
 * Creates and displays dialog with the given errorMsg.
 *///from   www  .  j  av a2s  .  c  o m
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:cm.aptoide.pt.Aptoide.java

private void requestUpdateSelf() {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
    alertBuilder.setCancelable(false)//from  w  ww .j  a v a2 s  .c o  m
            .setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    new DownloadSelfUpdate().execute();
                }
            }).setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    proceed();
                }
            }).setMessage(R.string.update_self_msg);

    AlertDialog alert = alertBuilder.create();

    alert.setTitle(R.string.update_self_title);
    alert.setIcon(R.drawable.icon);

    alert.show();
}

From source file:net.toload.main.hd.ui.ShareDialog.java

public void confirmShareDialog(final String imtype) {

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

    if (imtype.equalsIgnoreCase(Lime.DB_RELATED)) {
        alertDialog.setTitle(activity.getResources().getString(R.string.share_dialog_related_title));
        alertDialog.setMessage(activity.getResources().getString(R.string.share_dialog_related_title_message));
    } else {// ww w  .  j  ava2  s  .  co m
        alertDialog.setTitle(activity.getResources().getString(R.string.share_dialog_title));
        alertDialog.setMessage(activity.getResources().getString(R.string.share_dialog_title_message));
    }
    if (!imtype.equalsIgnoreCase(Lime.DB_RELATED)) {
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                activity.getResources().getString(R.string.share_lime_cin),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (imtype.equals(Lime.DB_RELATED)) {
                            // Call Share IM Processes
                            ((MainActivity) activity).initialShareRelated();
                            dismiss();
                            sharedialog.dismiss();
                        } else {
                            // Call Share IM Processes
                            ((MainActivity) activity).initialShare(imtype);
                            dismiss();
                            sharedialog.dismiss();
                        }
                    }
                });
    }

    alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
            activity.getResources().getString(R.string.share_lime_db), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    if (imtype.equals(Lime.DB_RELATED)) {
                        ((MainActivity) activity).initialShareRelatedDb();
                        dismiss();
                        sharedialog.dismiss();
                    } else {
                        // Call Share IM Processes
                        ((MainActivity) activity).initialShareDb(imtype);
                        dismiss();
                        sharedialog.dismiss();
                    }
                }
            });
    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
            activity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}

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

/**
 * ?/*from www  .j a v  a2 s .  c  o  m*/
 *
 * @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:cm.aptoide.pt.ManageRepo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.repolist);//from   w ww  .  j a  v a2 s  .c o  m

    db = new DbHandler(this);

    Intent i = getIntent();
    if (i.hasExtra("empty")) {
        final String uri = i.getStringExtra("uri");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.myrepo_alrt) + uri);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(uri);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        alrt.show();
    } else if (i.hasExtra("uri")) {
        String uri = i.getStringExtra("uri");
        Vector<String> new_serv_lst = getRemoteServLst(uri);
        for (final String srv : new_serv_lst) {
            AlertDialog alrt = new AlertDialog.Builder(this).create();
            alrt.setTitle(getString(R.string.title_repo_alrt));
            alrt.setIcon(android.R.drawable.ic_dialog_alert);
            alrt.setMessage(getString(R.string.newrepo_alrt) + srv);
            alrt.setButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    db.addServer(srv);
                    change = true;
                    redraw();
                    return;
                }
            });
            alrt.setButton2("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alrt.show();
        }
    } else if (i.hasExtra("newrepo")) {
        final String repo = i.getStringExtra("newrepo");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.newrepo_alrt) + repo);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(repo);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //exit
            }
        });
        alrt.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);
    alertBox.setMessage(message);//from   w ww  .j  a v  a  2  s .c o  m
    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:com.garrocho.MapActivity.java

@SuppressLint("NewApi")
@Override/*w  w  w .  jav a  2  s .com*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_map);
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            musica = null;
        } else {
            musica = extras.getString("MUSICA");
        }
    } else {
        musica = (String) savedInstanceState.getSerializable("MUSICA");
    }

    mPrefs = new SimpleGeofenceStore(this);
    Intent intent = new Intent();
    intent.putStringArrayListExtra(String.valueOf(GeofenceUtils.LISTA_GEOFENCES_ADDED), null);

    mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    if (mMap != null) {

        mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);

        mMap.setOnMapLongClickListener(new OnMapLongClickListener() {

            @Override
            public void onMapLongClick(final LatLng point) {
                CameraPosition INIT = new CameraPosition.Builder()
                        .target(new LatLng(point.latitude, point.longitude)).zoom(17.5F).build();
                mMap.animateCamera(CameraUpdateFactory.newCameraPosition(INIT));

                // TODO Auto-generated method stub
                String names[] = { "25", "50", "100", "200", "400" };
                final AlertDialog alertDialog = new AlertDialog.Builder(MapActivity.this,
                        android.R.style.Theme_Translucent).create();
                LayoutInflater inflater = getLayoutInflater();
                View convertView = (View) inflater.inflate(R.layout.custom, null);
                alertDialog.setView(convertView);
                alertDialog.setTitle("Selecione um Radius");
                ListView lv = (ListView) convertView.findViewById(R.id.listView1);
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(MapActivity.this,
                        android.R.layout.simple_list_item_1, names);
                lv.setAdapter(adapter);
                alertDialog.show();
                lv.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                        String item = ((TextView) arg1).getText().toString();

                        SimpleGeofence geofence = new SimpleGeofence(String.valueOf(mPrefs.getQtdeGeo() + 1),
                                point.latitude, point.longitude, Float.valueOf(item),
                                GEOFENCE_EXPIRATION_IN_MILLISECONDS, Geofence.GEOFENCE_TRANSITION_ENTER,
                                musica);

                        addMarkerForFence(geofence);
                        mPrefs.setGeofence(geofence.getId(), geofence);
                        lista.add(geofence.getId());
                        Intent intent = new Intent();
                        intent.putStringArrayListExtra(String.valueOf(GeofenceUtils.LISTA_GEOFENCES_ADDED),
                                lista);
                        MapActivity.this.setResult(Activity.RESULT_OK, intent);
                        alertDialog.dismiss();
                        Toast.makeText(MapActivity.this, "GeoFence Adicionada!", Toast.LENGTH_LONG).show();
                    }
                });
            }
        });

        desenharMakers();

        mMap.setMyLocationEnabled(true);

        Location location = mMap.getMyLocation();
        CameraPosition INIT = null;

        if (location == null) {
            locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
            location = getLastBestLocation();
        }

        INIT = new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude()))
                .zoom(17.5F).build();

        if (INIT != null)
            mMap.animateCamera(CameraUpdateFactory.newCameraPosition(INIT));
    }
}

From source file:org.smap.smapTask.android.activities.MainTabsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case PROGRESS_DIALOG:
        mProgressDialog = new ProgressDialog(this);
        DialogInterface.OnClickListener loadingButtonListener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();/*from w  w w.  j  a  va 2  s  .c  om*/
                mDownloadTasks.setDownloaderListener(null, mContext);
                mDownloadTasks.cancel(true);
                // Refresh the task list
                Intent intent = new Intent("refresh");
                LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
            }
        };
        mProgressDialog.setTitle(getString(R.string.downloading_data));
        mProgressDialog.setMessage(mProgressMsg);
        mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setButton(getString(R.string.cancel), loadingButtonListener);
        return mProgressDialog;
    case ALERT_DIALOG:
        mAlertDialog = new AlertDialog.Builder(this).create();
        mAlertDialog.setMessage(mAlertMsg);
        mAlertDialog.setTitle(getString(R.string.smap_get_tasks));
        DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int i) {
                dialog.dismiss();
            }
        };
        mAlertDialog.setCancelable(false);
        mAlertDialog.setButton(getString(R.string.ok), quitListener);
        mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
        return mAlertDialog;
    case PASSWORD_DIALOG:

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        final AlertDialog passwordDialog = builder.create();

        passwordDialog.setTitle(getString(R.string.enter_admin_password));
        final EditText input = new EditText(this);
        input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
        input.setTransformationMethod(PasswordTransformationMethod.getInstance());
        passwordDialog.setView(input, 20, 10, 20, 10);

        passwordDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String value = input.getText().toString();
                        String pw = mAdminPreferences.getString(AdminPreferencesActivity.KEY_ADMIN_PW, "");
                        if (pw.compareTo(value) == 0) {
                            Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class);
                            startActivity(i);
                            input.setText("");
                            passwordDialog.dismiss();
                        } else {
                            Toast.makeText(MainTabsActivity.this, getString(R.string.admin_password_incorrect),
                                    Toast.LENGTH_SHORT).show();
                            Collect.getInstance().getActivityLogger().logAction(this, "adminPasswordDialog",
                                    "PASSWORD_INCORRECT");
                        }
                    }
                });

        passwordDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel),
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        Collect.getInstance().getActivityLogger().logAction(this, "adminPasswordDialog",
                                "cancel");
                        input.setText("");
                        return;
                    }
                });

        passwordDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        return passwordDialog;
    }
    return null;
}

From source file:fm.smart.r1.activity.CreateItemActivity.java

public void onWindowFocusChanged(boolean bool) {
    super.onWindowFocusChanged(bool);
    Log.d("DEBUG", "onWindowFocusChanged");
    if (CreateItemActivity.create_item_result != null) {
        synchronized (CreateItemActivity.create_item_result) {
            final AlertDialog dialog = new AlertDialog.Builder(this).create();
            final boolean success = CreateItemActivity.create_item_result.success();
            final String item_id = CreateItemActivity.create_item_result.http_response;
            dialog.setTitle(CreateItemActivity.create_item_result.getTitle());
            dialog.setMessage(CreateItemActivity.create_item_result.getMessage());
            CreateItemActivity.create_item_result = null;
            dialog.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // TODO avoid moving to item view if previous thread was
                    // interrupted? create_item.isInterrupted() but need
                    // user to be aware if we
                    // have created example already - progress dialog is set
                    // cancelable, so back button will work? maybe should
                    // avoid encouraging cancel
                    // on POST operations ... not sure what to do if no
                    // response from server - guess we will time out
                    // eventually ...
                    if (success) {
                        // want to go to individual item screen now ...
                        ItemListActivity.loadItem(CreateItemActivity.this, item_id);
                    }// ww  w .j  a  v a 2 s. c om
                }
            });
            dialog.show();

        }
    }
}

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

/**
 * Edit entry based on selection in context menu
 *
 * @param info// www  .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 hostnameTextView = (TextView) v.findViewWithTag("hostname_" + position);
    TextView ipTextView = (TextView) v.findViewWithTag("ip_" + 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_redirection_dialog, null);
    final EditText hostnameEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    final EditText ipEditText = (EditText) dialogView.findViewById(R.id.list_dialog_ip);

    // set text from list
    hostnameEditText.setText(hostnameTextView.getText());
    ipEditText.setText(ipTextView.getText());

    // move cursor to end of EditText
    Editable hostnameEditContent = hostnameEditText.getText();
    hostnameEditText.setSelection(hostnameEditContent.length());
    Editable ipEditContent = ipEditText.getText();
    ipEditText.setSelection(ipEditContent.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 hostname = hostnameEditText.getText().toString();
                    String ip = ipEditText.getText().toString();

                    if (RegexUtils.isValidHostname(hostname)) {
                        if (RegexUtils.isValidIP(ip)) {
                            ProviderHelper.updateRedirectionListItemHostnameAndIp(mActivity, mCurrentRowId,
                                    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(sssemil.com.hostsaway.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(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();
}