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.bti360.hackathon.listview.HackathonActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case ADD_DIALOG:
        // We are going to create an AlertDialog with a single text input and a button
        // first we create the EditText
        final EditText edit = new EditText(this);
        // Next we create an AlertDialog.Builder which creates a styled AlertDialog based
        // on our specifications;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        // set the title
        builder.setTitle("Add Person");
        // set the icon to a built-in, this one is a +
        builder.setIcon(android.R.drawable.ic_input_add);
        // set the text of the only button, and add a click listener
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

            @Override/*from ww w  .  j  a  va2 s.  c om*/
            public void onClick(DialogInterface dialog, int which) {
                // on the Ok Button we grab the text from the EditText,
                // clear it and then add the Name to our list
                String name = edit.getText().toString();
                edit.setText("");
                addName(name);
            }
        });
        // finally let's create the dialog
        final AlertDialog d = builder.create();
        // and set the view to our EditText
        d.setView(edit);

        // we'll set a special InputType since we are collecting a name
        // other's exist such as email, address, phone number, etc
        // this allows the IME (keyboard) to customize itself based on
        // expected input, e.g. show @ and .com when Email
        edit.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
        // Respond to the default action on the IME (keyboard) By default it is
        // "Done" but it can be changed with setImeActionLabel to be something
        // else like a search hourglass.
        // In our case we want a click on "Done" to do the same thing as a click
        // on the Ok button in the Dialog.
        edit.setOnEditorActionListener(new OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView tv, int actionId, KeyEvent arg2) {
                // same as the DialogClick Handler except we also dismiss the dialog
                String name = edit.getText().toString();
                edit.setText("");
                addName(name);
                d.dismiss();
                return true;
            }
        });
        return d;
    }
    return super.onCreateDialog(id);
}

From source file:com.example.maproot.MainActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_A:// ww w  . ja  v  a  2  s .co m
        //show_mapInfo();
        return true;

    case MENU_B:
        //Legal Notices(?)

        String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(MainActivity.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();

        return true;

    case MENU_c:
        //show_settings();
        return true;

    }
    return false;
}

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

private void DialogConfirmRequest() {
    View dialogBoxView = View.inflate(this, R.layout.dialog_confirm_request, null);
    final Button btnAccept = (Button) dialogBoxView.findViewById(R.id.btnAccept);
    final Button btnReject = (Button) dialogBoxView.findViewById(R.id.btnReject);

    btnAccept.setOnClickListener(new View.OnClickListener() {
        @Override//from   www  . j  av  a  2 s  .com
        public void onClick(View v) {
            saveConfirm(request_id, "ACCEPT");
        }
    });
    btnReject.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveConfirm(request_id, "REJECT");
        }
    });
    /* 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:com.gigathinking.simpleapplock.ResetUnlockMethod.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_reset);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    mDialog = new ProgressDialog(this, ProgressDialog.STYLE_SPINNER);
    mDialog.setIndeterminate(true);/*from w  ww. ja  v  a2 s  .c  o  m*/
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    mResetReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            prefs.edit().putString(AppLockApplication.LOCKTYPE, AppLockApplication.LOCKTYPE_PIN).commit();
            prefs.edit()
                    .putString(AppLockApplication.PASSWORD, intent.getStringExtra(AppLockApplication.PASSWORD))
                    .commit();
            Toast.makeText(context, getString(R.string.pin_reset), Toast.LENGTH_LONG).show();
            startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            //startActivity(new Intent(ResetUnlockMethod.this,UnlockWithPIN.class).putExtra("test","test"));
            finish();
        }
    };
    LocalBroadcastManager.getInstance(this).registerReceiver(mResetReceiver,
            new IntentFilter(AppLockApplication.RESET_UNLOCK));

    if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.register_complete),
            false)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getString(R.string.reset_register_device));
        builder.setTitle(getString(R.string.info));
        builder.setPositiveButton(getString(R.string.register), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                new Register().execute();
                if (mDialog != null) {
                    mDialog.setMessage(getString(R.string.register_ongoing));
                    mDialog.show();
                }
                dialog.dismiss();
            }
        });
        builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_HOME);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        });
        builder.create().show();
    } else {
        if (mDialog != null) {
            mDialog.setMessage(getString(R.string.connect_to_server));
            mDialog.show();
        }
        new DoRequestReset().execute();
    }
}

From source file:com.vishnuvalleru.travelweatheralertsystem.MainActivity.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(MainActivity.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();/*  w  ww .  j  a  va2s. c  o  m*/
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.otaupdater.utils.KernelInfo.java

public void showUpdateDialog(final Context ctx) {
    AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
    alert.setTitle(R.string.alert_update_title);
    alert.setMessage(ctx.getString(R.string.alert_update_kernel_to, kernelName, version));

    alert.setPositiveButton(R.string.alert_download, new DialogInterface.OnClickListener() {
        @Override/*from www  . jav a 2s  . c  o  m*/
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.dismiss();

            final File file = new File(Config.KERNEL_DL_PATH_FILE, getDownloadFileName());
            if (file.exists()) {
                Log.v("OTA::Download", "Found old zip, checking md5");

                InputStream is = null;
                try {
                    is = new FileInputStream(file);
                    MessageDigest digest = MessageDigest.getInstance("MD5");
                    byte[] data = new byte[4096];
                    int nRead = -1;
                    while ((nRead = is.read(data)) != -1) {
                        digest.update(data, 0, nRead);
                    }
                    String oldMd5 = Utils.byteArrToStr(digest.digest());
                    Log.v("OTA::Download", "old zip md5: " + oldMd5);
                    if (!md5.equalsIgnoreCase(oldMd5)) {
                        file.delete();
                    } else {
                        //TODO show flash dialog
                        return;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    file.delete();
                } finally {
                    if (is != null) {
                        try {
                            is.close();
                        } catch (Exception e) {
                        }
                    }
                }
            }

            final long dlID = fetchFile(ctx);

            AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
            builder.setTitle(R.string.alert_downloading);
            builder.setMessage(ctx.getString(R.string.alert_downloading_changelog, changelog));
            builder.setCancelable(true);
            builder.setPositiveButton(R.string.alert_hide, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    DownloadManager dm = (DownloadManager) ctx.getSystemService(Context.DOWNLOAD_SERVICE);
                    dm.remove(dlID);
                }
            });
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    alert.create().show();
}

From source file:com.otaupdater.utils.RomInfo.java

public void showUpdateDialog(final Context ctx) {
    AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
    alert.setTitle(R.string.alert_update_title);
    alert.setMessage(ctx.getString(R.string.alert_update_rom_to, romName, version));

    alert.setPositiveButton(R.string.alert_download, new DialogInterface.OnClickListener() {
        @Override//from   w  w  w.  j  a  v a  2  s  .  c  o  m
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.dismiss();

            final File file = new File(Config.ROM_DL_PATH_FILE, getDownloadFileName());
            if (file.exists()) {
                Log.v("OTA::Download", "Found old zip, checking md5");

                InputStream is = null;
                try {
                    is = new FileInputStream(file);
                    MessageDigest digest = MessageDigest.getInstance("MD5");
                    byte[] data = new byte[4096];
                    int nRead = -1;
                    while ((nRead = is.read(data)) != -1) {
                        digest.update(data, 0, nRead);
                    }
                    String oldMd5 = Utils.byteArrToStr(digest.digest());
                    Log.v("OTA::Download", "old zip md5: " + oldMd5);
                    if (!md5.equalsIgnoreCase(oldMd5)) {
                        file.delete();
                    } else {
                        //TODO show flash dialog
                        return;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    file.delete();
                } finally {
                    if (is != null) {
                        try {
                            is.close();
                        } catch (Exception e) {
                        }
                    }
                }
            }

            final long dlID = fetchFile(ctx);

            AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
            builder.setTitle(R.string.alert_downloading);
            builder.setMessage(ctx.getString(R.string.alert_downloading_changelog, changelog));
            builder.setCancelable(true);
            builder.setPositiveButton(R.string.alert_hide, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    DownloadManager dm = (DownloadManager) ctx.getSystemService(Context.DOWNLOAD_SERVICE);
                    dm.remove(dlID);
                }
            });
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    alert.create().show();
}

From source file:cn.count.easydrive366.signup.Step3Activity.java

private void chooseDriverType() {
    final JSONArray list = AppSettings.driver_type_list;
    if (list == null) {
        return;//from   ww w  . j  av a 2 s  .c o  m
    }
    String types = edtCar_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) {

                    changeDriverType();
                }
            });
    builder.setNegativeButton(this.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                }
            });
    builder.show();
}

From source file:com.jonbanjo.cupsprint.CertificateActivity.java

public void doimport(View view) {
    try {/*from  w  w w . j  av  a 2s .  c o m*/
        String url = "https://" + host.getText().toString() + ":" + port.getText().toString();
        importButton.setEnabled(false);
        new importer().execute(url).get(3000, TimeUnit.MILLISECONDS);
    } catch (Exception e) {

    } finally {
        importButton.setEnabled(true);
    }
    if (certChain == null) {
        return;
    }

    for (X509Certificate cert : certChain) {
        try {
            cert.checkValidity();
        } catch (Exception e) {
            showToast(e.toString());
            return;
        }

    }
    String certString = certChain[0].toString();
    final String alias = certChain[0].getSubjectX500Principal().getName();
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Add Certificate?").setMessage(certString)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    try {
                        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
                        keyPairGenerator.initialize(1024);
                        KeyPair keyPair = keyPairGenerator.generateKeyPair();
                        PrivateKey privateKey = keyPair.getPrivate();
                        trustStore.setKeyEntry(alias, privateKey, JfSSLScheme.password.toCharArray(),
                                certChain);
                        FileOutputStream outputStream = openFileOutput(JfSSLScheme.trustfile, MODE_PRIVATE);
                        trustStore.store(outputStream, JfSSLScheme.password.toCharArray());
                        outputStream.flush();
                        outputStream.close();
                        certListAdaptor.add(alias);
                    } catch (Exception e) {
                        System.out.println(e.toString());
                        return;
                    }
                }
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog dialog = builder.create();
    dialog.show();

}