Example usage for android.app AlertDialog.Builder setIcon

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

Introduction

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

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

From source file:com.money.manager.ex.MainActivity.java

/**
 * Dialog to choose exit from application
 *///ww  w  .j  a va  2s.  c  o  m
public void exitApplication() {
    AlertDialog.Builder exitDialog = new AlertDialog.Builder(this);
    exitDialog.setTitle(R.string.close_application);
    exitDialog.setMessage(R.string.question_close_application);
    exitDialog.setIcon(R.drawable.ic_launcher);
    exitDialog.setPositiveButton(android.R.string.yes, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            MoneyManagerApplication.killApplication();
        }
    });
    exitDialog.setNegativeButton(android.R.string.no, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    // show dialog
    exitDialog.create().show();
}

From source file:com.pranavpandey.smallapp.permission.PermissionSelectExternalStorage.java

private void buildPermissionsDialog() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    View view = getLayoutInflater().inflate(R.layout.sas_dialog_permission, new LinearLayout(this), false);
    ViewGroup frame = (ViewGroup) view.findViewById(R.id.permission_frame);

    String label = getApplicationInfo().loadLabel(getPackageManager()).toString();
    ((TextView) view.findViewById(R.id.permission_message))
            .setText(String.format(getString(R.string.sas_format_next_line),
                    getString(R.string.sas_select_external_storage_request_desc),
                    String.format(getString(R.string.sas_select_external_storage_request_info), label)));

    frame.addView(new PermissionItem(this, ContextCompat.getDrawable(this, R.drawable.sas_ic_select_storage),
            getString(R.string.sas_select_external_storage),
            getString(R.string.sas_select_external_storage_desc)));

    try {/*  www  .j  av  a2s  .c o m*/
        alertDialogBuilder.setIcon(
                DynamicTheme.createDialogIcon(this, getPackageManager().getApplicationIcon(getPackageName())));
    } catch (Exception e) {
        e.printStackTrace();
    }
    alertDialogBuilder.setTitle(label)
            .setPositiveButton(R.string.sas_perm_continue, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    triggerStorageAccessFramework();
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    finish();
                }
            }).setCancelable(false);

    final AlertDialog dialog = alertDialogBuilder.create();
    dialog.setView(view, 0, SmallUtils.getDialogTopPadding(this), 0, 0);

    showPermissionDialog(dialog);
}

From source file:com.shafiq.mytwittle.view.HomeActivity.java

private void showFreeForLifeSuccess() {
    AlertDialog.Builder builder = new AlertDialog.Builder(HomeActivity.this);

    builder.setMessage(getString(R.string.free_for_life_success));
    builder.setTitle(getString(R.string.success));
    builder.setIcon(android.R.drawable.btn_star_big_on);

    builder.setPositiveButton("OK", new Dialog.OnClickListener() {

        @Override//from  w w w .  j  a  v a  2s.co m
        public void onClick(DialogInterface arg0, int arg1) {

        }

    });

    builder.create().show();
}

From source file:at.jclehner.rxdroid.DrugListActivity.java

@SuppressWarnings("deprecation")
@Override/*from   w  w w . j  a v a  2 s  .  com*/
protected Dialog onCreateDialog(final int id, Bundle args) {
    if (id == R.id.dose_dialog)
        return new DoseDialog(this);
    else if (id == DIALOG_INFO) {
        final String msg = args.getString("msg");
        final String onceId = args.getString("once_id");

        final AlertDialog.Builder ab = new AlertDialog.Builder(this);
        ab.setIcon(android.R.drawable.ic_dialog_info);
        ab.setTitle(R.string._title_info);
        ab.setMessage(msg);
        ab.setCancelable(false);
        ab.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Log.d(TAG, "onClick: which = " + which);
                Settings.setDisplayedOnce(onceId);
                removeDialog(id);
            }
        });

        return ab.create();
    }

    return super.onCreateDialog(id, args);
}

From source file:com.charabia.SmsViewActivity.java

public void buttonAbout(View view) {
    try {/*from  w w w.j a v a2  s  .  co  m*/
        PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.app_name));
        builder.setMessage(getString(R.string.info, pi.versionName));
        builder.setIcon(R.drawable.ic_launcher);
        builder.setPositiveButton(R.string.quit, null);
        builder.show();
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:com.myandroidremote.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *//*from ww  w. j  av  a2  s .com*/
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                showLoadingScreen();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Register in the background and terminate the activity
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                register((String) account.getText());

                // show connecting
                showLoadingScreen();
            }
        });

        final Button exitButton = (Button) findViewById(R.id.exit);
        exitButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });
    }
}

From source file:com.renard.ocr.BaseDocumentActivitiy.java

@Override
protected Dialog onCreateDialog(int id, Bundle args) {
    switch (id) {

    case PDF_PROGRESS_DIALOG_ID:
        int max = args.getInt(DIALOG_ARG_MAX);
        String message = args.getString(DIALOG_ARG_MESSAGE);
        String title = args.getString(DIALOG_ARG_TITLE);
        pdfProgressDialog = new ProgressDialog(this);
        pdfProgressDialog.setMessage(message);
        pdfProgressDialog.setTitle(title);
        pdfProgressDialog.setIndeterminate(false);
        pdfProgressDialog.setMax(max);/*from  ww  w  .  ja v a  2  s . c om*/
        pdfProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        pdfProgressDialog.setCancelable(false);
        return pdfProgressDialog;
    case DELETE_PROGRESS_DIALOG_ID:
        max = args.getInt(DIALOG_ARG_MAX);
        message = args.getString(DIALOG_ARG_MESSAGE);
        deleteProgressDialog = new ProgressDialog(this);
        deleteProgressDialog.setMessage(message);
        deleteProgressDialog.setIndeterminate(false);
        deleteProgressDialog.setMax(max);
        deleteProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        deleteProgressDialog.setCancelable(false);
        return deleteProgressDialog;
    case EDIT_TITLE_DIALOG_ID:
        View layout = getLayoutInflater().inflate(R.layout.edit_title_dialog, null);
        final Uri documentUri = Uri.parse(args.getString(DIALOG_ARG_DOCUMENT_URI));
        final String oldTitle = args.getString(DIALOG_ARG_TITLE);
        final EditText edit = (EditText) layout.findViewById(R.id.edit_title);
        edit.setText(oldTitle);

        AlertDialog.Builder builder = new Builder(this);
        builder.setView(layout);
        builder.setTitle(R.string.edit_dialog_title);
        builder.setIcon(R.drawable.fairy_showing);
        builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                final String title = edit.getText().toString();
                saveTitle(title, documentUri);

            }
        });
        builder.setNegativeButton(R.string.cancel, new OnClickListener() {

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

            }
        });
        builder.show();
    }
    return super.onCreateDialog(id, args);
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java

public void requestSave() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.editor_save_request);
    builder.setCancelable(false);// w w w .  j  a  va  2  s  .  co m
    builder.setMessage(Html.fromHtml(getString(R.string.editor_save_description)));
    builder.setIcon(R.drawable.ic_save);
    builder.setPositiveButton(R.string.editor_save, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            save(true);
            dialog.dismiss();
        }
    });
    builder.setNegativeButton(R.string.editor_discard, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            dialog.dismiss();
            finish();
        }
    });
    builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
    TextView messageText = (TextView) alert.findViewById(android.R.id.message);
    messageText.setGravity(Gravity.CENTER);
}

From source file:com.p3authentication.preferences.Prefs.java

protected void hideLauncherIcon() {
    // TODO Auto-generated method stub

    AlertDialog.Builder builder = new AlertDialog.Builder(Prefs.this);
    builder.setTitle("Important!");
    builder.setMessage(/*from   w  ww .  ja v a2s  .  c  o  m*/
            "To launch P3 again, dial " + AccessPin.getText().toString() + " or set up your custom Pin below.");
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Prefs.this.getPackageManager().setComponentEnabledSetting(LAUNCHER_COMPONENT_NAME,
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

        }
    });
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.show();
    ComponentName receiver = new ComponentName(Prefs.this, NumberListerner.class);
    PackageManager pm = Prefs.this.getPackageManager();

    pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
            PackageManager.DONT_KILL_APP);
    AccessPin.setEnabled(true);

}

From source file:falcofinder.android.fuehrerschein.chat.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *///from  w  ww . j av a  2s.  c  om
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);

        /* 
         * rimuovo aggiunta account perche' disponible da versione 2.2
         * ma voglio compatibilita' con 2.1
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
        }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }
        });
        */

        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();

    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Set "connecting" status
                SharedPreferences prefs = Util.getSharedPreferences(mContext);
                prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit();
                // Get account name
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                // Register
                register((String) account.getText());
                finish();
            }
        });
    }
}