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:tcc.iesgo.activity.ClientMapActivity.java

@Override
public void onProviderDisabled(String arg0) {
    final AlertDialog.Builder dialog = new AlertDialog.Builder(getParent());
    dialog.setTitle(getString(R.string.gps_disabled));
    dialog.setMessage(getString(R.string.gps_disabled_message));
    dialog.setIcon(R.drawable.gps_enable);
    dialog.setCancelable(false);//from  w w  w.  j  a v  a 2  s  . com

    dialog.setPositiveButton(getString(R.string.ad_button_positive), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
    });

    dialog.setNegativeButton(getString(R.string.ad_button_negative), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            finish();
        }
    });
    dialog.show();
}

From source file:com.thanu.schoolbustracker.RouteActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_legalnotices:
        String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(RouteActivity.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();/*from w w  w .j  a v  a  2s.c  o m*/
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:cn.count.easydrive366.DriverLicenseEditActivity.java

private void chooseDriverType() {
    final JSONArray list = AppSettings.driver_type_list;
    if (list == null) {
        return;/*  www  .  j av  a2  s  .com*/
    }
    String types = ((TextView) findViewById(R.id.edt_driverlicense_car_type)).getText().toString();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    MultiChoiceID.clear();
    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle(this.getResources().getString(R.string.app_name));

    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)) {
                    int i_index = MultiChoiceID.indexOf(which);
                    MultiChoiceID.remove(i_index);
                }
            }

        }
    });
    builder.setPositiveButton(this.getResources().getString(R.string.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(this.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                }
            });
    builder.show();
}

From source file:microsoft.aspnet.signalr.client.test.integration.android.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        startActivity(new Intent(this, SignalRPreferenceActivity.class));
        return true;

    case R.id.menu_run_tests:
        if (ApplicationContext.getServerUrl().trim().equals("")) {
            startActivity(new Intent(this, SignalRPreferenceActivity.class));
        } else {/*from w w w. j  a  v  a2 s. c o m*/
            runTests();
        }
        return true;

    case R.id.menu_check_all:
        changeCheckAllTests(true);
        return true;

    case R.id.menu_uncheck_all:
        changeCheckAllTests(false);
        return true;

    case R.id.menu_reset:
        refreshTestGroupsAndLog();
        return true;

    case R.id.menu_view_log:
        AlertDialog.Builder logDialogBuilder = new AlertDialog.Builder(this);
        logDialogBuilder.setTitle("Log");

        final WebView webView = new WebView(this);

        String logContent = TextUtils.htmlEncode(mLog.toString()).replace("\n", "<br />");
        String logHtml = "<html><body><pre>" + logContent + "</pre></body></html>";
        webView.loadData(logHtml, "text/html", "utf-8");

        logDialogBuilder.setPositiveButton("Copy", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                clipboardManager.setText(mLog.toString());
            }
        });

        final String postContent = mLog.toString();

        logDialogBuilder.setNeutralButton("Post data", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                new AsyncTask<Void, Void, Void>() {

                    @Override
                    protected Void doInBackground(Void... params) {
                        try {
                            String url = ApplicationContext.getLogPostURL();
                            if (url != null && url.trim() != "") {
                                url = url + "?platform=android";
                                HttpPost post = new HttpPost();
                                post.setEntity(new StringEntity(postContent, "utf-8"));

                                post.setURI(new URI(url));

                                new DefaultHttpClient().execute(post);
                            }
                        } catch (Exception e) {
                            // Wasn't able to post the data. Do nothing
                        }

                        return null;
                    }
                }.execute();
            }
        });

        logDialogBuilder.setView(webView);

        logDialogBuilder.create().show();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:nl.terr.tabweave.TabWeave.java

public AlertDialog createAlertDialog(Context context, String sTitle, String sMessage) {
    AlertDialog.Builder builder = new AlertDialog.Builder(TabWeave.this);
    builder.setTitle(sTitle).setMessage(sMessage).setCancelable(false)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                }//from  ww  w .ja v a 2s .c  om
            });
    AlertDialog alert = builder.create();

    return alert;
}

From source file:com.cloudkick.NodeViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.do_connectbot:
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String user = prefs.getString("sshUser", "root");
        Integer port = new Integer(prefs.getString("sshPort", "22"));
        String uri = "ssh://" + user + "@" + node.ipAddress + ":" + port + "/#" + user;
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        try {/*from   w  w  w. ja v a 2 s . c  om*/
            startActivity(i);
        } catch (ActivityNotFoundException e) {
            // Suggest ConnectBot
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("SSH Client Not Found");
            String mfaMessage = ("The ConnectBot SSH Client is required to complete this operation. "
                    + "Would you like to install ConnectBot from the Android Market now?");
            builder.setMessage(mfaMessage);
            builder.setCancelable(true);
            builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent marketActivity = new Intent(Intent.ACTION_VIEW);
                    marketActivity.setData(Uri.parse("market://details?id=org.connectbot"));
                    startActivity(marketActivity);
                }
            });
            builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            AlertDialog mfaDialog = builder.create();
            mfaDialog.show();
        }
        return true;
    default:
        // If its not recognized, do nothing
        return super.onOptionsItemSelected(item);
    }
}

From source file:tm.veriloft.mapsplayground.MapsActivity.java

/**
 * This is where we can add markers or lines, add listeners or move the camera. In this case, we
 * just add a marker near Africa.//  ww w. ja  va  2s  . co  m
 * <p>
 * This should only be called once and when we are sure that {@link #mMap} is not null.
 */
private void setUpMap() {
    mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    mMap.setMyLocationEnabled(true);

    mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
        @Override
        public void onMapLongClick(final LatLng latLng) {

            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MapsActivity.this);
            alertDialogBuilder.setTitle("Confirm Route Drawing");

            alertDialogBuilder.setMultiChoiceItems(drawOptionsStrings, drawOptionsValues,
                    new DialogInterface.OnMultiChoiceClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                            drawOptionsValues[which] = isChecked;
                            setDrawOptionsValues();
                        }
                    });

            alertDialogBuilder.setNegativeButton("Nope", null);
            alertDialogBuilder.setPositiveButton("Yes, of coz", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Location location = mMap.getMyLocation();

                    if (location != null) {
                        fetchAndDrawRoute(new LatLng(location.getLatitude(), location.getLongitude()), latLng);
                    } else {
                        showCenteredToast("Your current location currently not available, please wait.");
                    }
                }
            });
            alertDialogBuilder.show();
        }
    });

    mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            l("onMapClick, " + latLng.toString());
        }
    });

    focusTo(new LatLng(37.945958662069174, 58.38305085897446), 13); // focus to ashgabat
}

From source file:com.phonegap.Notification.java

/**
 * Builds and shows a native Android confirm dialog with given title, message, buttons.
 * This dialog only shows up to 3 buttons.  Any labels after that will be ignored.
 * The index of the button pressed will be returned to the JavaScript callback identified by callbackId.
 * /*from ww w  .ja  v  a2  s .c o m*/
 * @param message       The message the dialog should display
 * @param title       The title of the dialog
 * @param buttonLabels    A comma separated list of button labels (Up to 3 buttons)
 * @param callbackId   The callback id
 */
public synchronized void confirm(final String message, final String title, String buttonLabels,
        final String callbackId) {

    final PhonegapActivity ctx = this.ctx;
    final Notification notification = this;
    final String[] fButtons = buttonLabels.split(",");

    Runnable runnable = new Runnable() {
        public void run() {
            AlertDialog.Builder dlg = new AlertDialog.Builder(ctx);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);

            // First button
            if (fButtons.length > 0) {
                dlg.setPositiveButton(fButtons[0], new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        notification.success(new PluginResult(PluginResult.Status.OK, 1), callbackId);
                    }
                });
            }

            // Second button
            if (fButtons.length > 1) {
                dlg.setNeutralButton(fButtons[1], new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        notification.success(new PluginResult(PluginResult.Status.OK, 2), callbackId);
                    }
                });
            }

            // Third button
            if (fButtons.length > 2) {
                dlg.setNegativeButton(fButtons[2], new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        notification.success(new PluginResult(PluginResult.Status.OK, 3), callbackId);
                    }
                });
            }

            dlg.create();
            dlg.show();
        };
    };
    this.ctx.runOnUiThread(runnable);
}

From source file:net.heroicefforts.viable.android.BugReporterActivity.java

/**
 * Issue already exists.  Now prompt the user whether they want to add an additional comment.
 *  //from ww w .ja  v a 2s. c  o m
 * @param issue the defect
 */
private void showSupplementDialog(Issue issue) {
    if (Config.LOGD)
        Log.d(TAG, "Prompting user to comment on existing issue '" + issue.getIssueId() + "'.");
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.bug_comment);
    builder.setCancelable(true);
    builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            comment = true;
        }
    });
    builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }
    });
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            finish();
        }
    });
    builder.setMessage(getString(R.string.bug_comment_prompt).replaceAll("\\{appName\\}", issue.getAppName()));
    builder.create().show();
}

From source file:tm.veriloft.mapsplayground.MapsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.map_routes_clear:

        //clear them from map
        for (Polyline drawnRoute : drawnRoutes)
            drawnRoute.remove();/* ww w . j  a  v  a2 s  . co m*/
        for (Marker marker : addedMarkers)
            marker.remove();

        //clear array
        drawnRoutes.clear();
        addedMarkers.clear();

        break;
    case R.id.map_type:
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MapsActivity.this);
        alertDialogBuilder.setTitle("Choose map type");

        alertDialogBuilder.setSingleChoiceItems(mapTypeStrings, lastMapType,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        if (which == lastMapType)
                            return;

                        lastMapType = which;

                        switch (which) {
                        case 0:
                            mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
                            break;
                        case 1:
                            mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
                            break;
                        case 2:
                            mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
                            break;
                        case 3:
                            mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
                            break;
                        }
                    }
                });
        alertDialogBuilder.setNegativeButton("Cancel", null);
        alertDialogBuilder.show();
        break;
    }
    return true;
}