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:at.jclehner.androidutils.AlertDialogFragment.java

@Override
public final Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
    ab.setTitle(getTitle());/*from   w ww  .j  av a 2s .co m*/
    ab.setMessage(getMessage());
    ab.setIcon(getIcon());

    // listeners are null because we use View.OnClickListener instead
    // of DialogInterface.OnClickListener
    ab.setPositiveButton(getPositiveButtonText(), null);
    ab.setNeutralButton(getNeutralButtonText(), null);
    ab.setNegativeButton(getNegativeButtonText(), null);

    onPrepareDialogBuilder(ab);

    final AlertDialog dialog = ab.create();
    dialog.setOnShowListener(mOnShowListener);

    return dialog;
}

From source file:com.techjoynt.android.nxt.activity.RemoteControl.java

private AlertDialog noBluetoothOnDevice() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle(R.string.no_bluetooth);
    builder.setIcon(R.drawable.ic_action_bluetooth);
    builder.setMessage(R.string.no_bluetooth_message);

    builder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {

        @Override// w  w  w. j  av  a2s  .c o m
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            finish();
        }
    });

    return builder.create();
}

From source file:com.acdd.homelauncher.fragment.InstalledAppFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    String location = (String) parent.getAdapter().getItem(position);
    final PackageLite packageLite = ACDD.getInstance().getBundlePackageLite(location);
    if (packageLite != null) {

        AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
        //?/*  w  w w  . j a v a  2s  .  co m*/
        builder.setIcon(R.mipmap.ic_launcher);
        //?
        builder.setTitle("??");
        //0: ?
        final String[] comp = new String[packageLite.components.size()];
        packageLite.components.toArray(comp);
        builder.setSingleChoiceItems(comp, 0, new AlertDialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String className = (String) (comp[which]);
                if (!className.contains("Activity")) {
                    Toast.makeText(getActivity(), "Support Activity Only", Toast.LENGTH_SHORT).show();
                    dialog.dismiss();
                    return;
                }
                Intent mIntent = new Intent();
                mIntent.setClassName(getActivity(), className);
                startActivity(mIntent);
                dialog.dismiss();
            }
        });

        //
        builder.setPositiveButton("   ", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        //??
        builder.create().show();

    }
}

From source file:br.ufg.inf.es.fs.contpatri.mobile.webservice.EnviarColeta.java

/**
 * Mtodo que exibe um <code>Dialog</code> caso haja erro no login do
 * usurio no aplicativo./*  ww w. j  av a 2  s. co  m*/
 */
private void mostrarDialogo() {

    AlertDialog.Builder builder;
    builder = new AlertDialog.Builder(activity);

    builder.setTitle("Erro");
    builder.setMessage(mensagem);
    builder.setIcon(android.R.drawable.ic_dialog_alert);

    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            dialog.dismiss();
        }
    });

    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();

}

From source file:com.darizotas.metadatastrip.FileDetailFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the metadata from the selected file.
    if (getArguments().containsKey(ARG_ITEM_ID)) {
        File file = new File(getArguments().getString(ARG_ITEM_ID));

        MetaDataExtractorProxy proxy = MetaDataExtractorProxy.getInstance();
        mFileMetadata = null;/* w  w w  .  j av  a 2  s. c o m*/
        try {
            mFileMetadata = proxy.extract(file);

            // Error opening the file.
        } catch (IOException e) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setIcon(R.drawable.ic_launcher)
                    .setTitle("[" + file.getName() + "] " + getResources().getText(R.string.error_open_file))
                    .setPositiveButton("OK", null).show();
            // Error processing metadata.
        } catch (MetadataProcessingException e) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setIcon(R.drawable.ic_launcher)
                    .setTitle("[" + file.getName() + "] " + getResources().getText(R.string.error_process_file))
                    .setMessage(e.getMessage()).setPositiveButton("OK", null).show();
        }

        setHasOptionsMenu(true);
    }
}

From source file:com.techjoynt.android.nxt.activity.RemoteControl.java

private AlertDialog bluetoothNotTurnedOn() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle(R.string.bluetooth_required);
    builder.setIcon(R.drawable.ic_action_bluetooth);
    builder.setMessage(R.string.bluetooth_required_message);

    builder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
        @Override//w  w  w. ja v a2  s.  c om
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            finish();
        }
    });

    return builder.create();
}

From source file:com.alphabetbloc.accessmrs.ui.user.BaseUserActivity.java

private void showRequestSyncDialog() {
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override//from w ww. ja va 2 s.  co m
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                SyncManager.sStartSync.set(true);
                updateSyncProgress();
                dialog.dismiss();
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                SyncManager.sCancelSync.set(true);
                break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setTitle(getString(R.string.refresh_clients_title));
    builder.setMessage(getString(R.string.refresh_clients_text));
    builder.setPositiveButton(getString(R.string.refresh), dialogClickListener);
    builder.setNegativeButton(getString(R.string.cancel), dialogClickListener);
    mRequestSyncDialog = builder.create();
    mRequestSyncDialog.show();
}

From source file:org.dkf.jmule.util.DangerousPermissionsChecker.java

private boolean onExternalStoragePermissionsResult(String[] permissions, int[] grantResults) {
    if (!Ref.alive(activityRef)) {
        return false;
    }//from   www  .  j  a v  a 2  s  .c om
    final Activity activity = activityRef.get();
    for (int i = 0; i < permissions.length; i++) {
        if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
            if (permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    || permissions[i].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
                AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                builder.setIcon(R.drawable.sd_card_notification);
                builder.setTitle(R.string.why_we_need_storage_permissions);
                builder.setMessage(R.string.why_we_need_storage_permissions_summary);
                builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        shutdownFrostWire();
                    }
                });
                builder.setPositiveButton(R.string.request_again, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        requestPermissions();
                    }
                });
                AlertDialog alertDialog = builder.create();
                alertDialog.show();
                return false;
            }
        }
    }
    return true;
}

From source file:org.traccar.client.MainFragment.java

private void removeLauncherIcon() {
    String className = MainActivity.class.getCanonicalName().replace(".MainActivity", ".Launcher");
    ComponentName componentName = new ComponentName(getActivity().getPackageName(), className);
    PackageManager packageManager = getActivity().getPackageManager();
    if (packageManager
            .getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
        packageManager.setComponentEnabledSetting(componentName,
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setMessage(getString(R.string.hidden_alert));
        builder.setPositiveButton(android.R.string.ok, null);
        builder.show();//w  ww. j a v a 2 s  .c o m
    }
}

From source file:com.synvata.modules.DriverLicenseEditActivity.java

private void chooseDriverType() {
    final JSONArray list = AppSettings.driver_type_list;
    if (list == null) {
        return;//from  w ww . j a v  a  2s.c o  m
    }
    String types = ((EditText) findViewById(R.id.edt_driverlicense_car_type)).getText().toString();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    MultiChoiceID.clear();
    builder.setIcon(R.drawable.index_looks);
    builder.setTitle("Please choose");

    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))
                    MultiChoiceID.remove(which);
            }

        }
    });
    builder.setPositiveButton("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("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

        }
    });
    builder.show();
}