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.xperia64.timidityae.PlaylistFragment.java

public void add() {
    if (mode) {//w  w  w.  j  av a 2 s  .  c o m
        vola = parsePlist(tmpName = plistName);
        AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity());
        loki = vola.size();

        builderSingle.setIcon(R.drawable.ic_launcher);
        builderSingle.setTitle(getResources().getString(R.string.plist_addto));
        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(),
                android.R.layout.select_dialog_item);
        arrayAdapter.add(getResources().getString(R.string.plist_addcs));
        arrayAdapter.add(getResources().getString(R.string.plist_adds));
        arrayAdapter.add(getResources().getString(R.string.plist_addf));
        arrayAdapter.add(getResources().getString(R.string.plist_addft));
        builderSingle.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                vola = parsePlist(plistName);
                switch (which) {
                case 0:
                    setItem(((TimidityActivity) getActivity()).currSongName, 0);
                    write();
                    break;
                case 1:
                    new FileBrowserDialog().create(0,
                            (((Globals.showVideos) ? Globals.musicVideoFiles : Globals.musicFiles)),
                            PlaylistFragment.this, getActivity(), getActivity().getLayoutInflater(), false,
                            Globals.defaultFolder, getActivity().getResources().getString(R.string.fb_add));
                    break;
                case 2:
                    new FileBrowserDialog().create(1, null, PlaylistFragment.this, getActivity(),
                            getActivity().getLayoutInflater(), false, Globals.defaultFolder,
                            getActivity().getResources().getString(R.string.fb_add));
                    break;
                case 3:
                    new FileBrowserDialog().create(2, null, PlaylistFragment.this, getActivity(),
                            getActivity().getLayoutInflater(), false, Globals.defaultFolder,
                            getActivity().getResources().getString(R.string.fb_add));
                    break;
                }
            }
        });
        builderSingle.show();
    } else {
        AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());

        alert.setTitle(getResources().getString(R.string.plist_crea));

        final EditText input = new EditText(getActivity());
        alert.setView(input);

        alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

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

            }
        });
        alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                String value = input.getText().toString();
                File f = new File(playlistDir + value + ".tpl");

                if (!f.exists()) {
                    String[] needLol = null;
                    try {
                        new FileOutputStream(playlistDir + value + ".tpl").close();
                    } catch (FileNotFoundException e) {
                        needLol = Globals.getDocFilePaths(getActivity(), playlistDir);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    if (needLol != null) {
                        Globals.tryToCreateFile(getActivity(), playlistDir + value + ".tpl");
                    } else {
                        new File(playlistDir + value + ".tpl").delete();
                        try {
                            f.createNewFile();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }

                getPlaylists(null);
                dialog.dismiss();
            }

        });
        alert.show();
    }
}

From source file:mp.paschalis.RequestActivity.java

/**
 * Replies to request of user//  w w  w.  ja va 2 s  .c  o m
 */
private void hButtonDeleteRequest() {
    buttonHybrid.setText(R.string.deleteRequest);

    buttonHybrid.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(RequestActivity.this);
                alert.setTitle(R.string.msg_sure);

                alert.setIcon(R.drawable.ic_dialog_alert_holo_light);

                alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() {

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

                alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Delete a request
                        LentBookActivity.DataClassLentABook d = new LentBookActivity.DataClassLentABook();
                        d.destinationUser = dataClassActivities.username;
                        d.isbn = dataClassActivities.book.isbn;

                        new AsyncTaskDeleteABookRequest().execute(d);
                    }
                });

                alert.show();

            }

        }
    });

}

From source file:com.moro.synapsemod.MainActivity.java

private void confirmar_restaurar(final String backup) {

    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    adb.setTitle(R.string.dlg_conf_title);
    adb.setIcon(R.drawable.ic_alert);
    adb.setMessage(getString(R.string.dlg_conf_message, backup));
    adb.setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
        @Override/* ww  w  . ja v a  2  s.c o  m*/
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

            // Guardo boolean true para el cambio automatico del perfil
            SharedPreferences prefs = getSharedPreferences("moro_prefs", Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt("aplicar_cambios_auto", 1);
            editor.commit();

            // Restauramos perfil
            Utils.runCommand(BB + " mount -o remount,rw /", false);
            Utils.runCommand("/res/synapse/actions/sqlite ImportConfigSynapse " + backup, false);
            Utils.runCommand("/res/synapse/uci restart", false);
            Utils.runCommand(BB + " mount -o remount,ro /", false);
        }
    });
    adb.setNegativeButton(R.string.btn_no, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    adb.create().show();
}

From source file:mp.paschalis.RequestActivity.java

/**
 * Lents a book to user/*from w  ww.  j  av a  2  s.co m*/
 */
private void hButtonLentABook() {
    buttonHybrid.setText(R.string.lent);

    buttonHybrid.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            {
                AlertDialog.Builder alert = new AlertDialog.Builder(RequestActivity.this);
                alert.setTitle(R.string.msg_sure);

                alert.setIcon(R.drawable.ic_menu_back);

                alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() {

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

                alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Lent a book
                        LentBookActivity.DataClassLentABook data = new LentBookActivity.DataClassLentABook();

                        data.destinationUser = dataClassActivities.username;
                        data.isbn = dataClassActivities.book.isbn;

                        new AsyncTaskLentABook_Activities().execute(data);
                    }
                });

                alert.show();

            }

        }
    });

}

From source file:de.eidottermihi.rpicheck.fragment.RunCommandDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    this.device = (RaspberryDeviceBean) this.getArguments().getSerializable("pi");
    this.command = (CommandBean) this.getArguments().getSerializable("cmd");
    if (this.getArguments().getString("passphrase") != null) {
        this.passphrase = this.getArguments().getString("passphrase");
    }/*from w w w.  ja v  a 2 s  .  c  o  m*/

    builder.setTitle(getString(R.string.run_cmd_dialog_title, this.command.getName()));

    // fetching the theme-dependent icon
    TypedValue icon = new TypedValue();
    if (getActivity().getTheme().resolveAttribute(R.attr.ic_dialog_run, icon, true)) {
        builder.setIcon(icon.resourceId);
    }

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

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // just closing the dialog
        }
    });
    final LayoutInflater inflater = getActivity().getLayoutInflater();
    final View view = inflater.inflate(R.layout.dialog_command_run, null);
    builder.setView(view);
    consoleOutput = (TextView) view.findViewById(R.id.runCommandOutput);
    consoleOutput.setMovementMethod(new ScrollingMovementMethod());
    if (savedInstanceState != null) {
        this.didRun = savedInstanceState.getBoolean("didRun", false);
    }
    return builder.create();
}

From source file:net.evecom.android.web.WebdbActivity.java

/**
 * //  w  ww.  j  a va2 s .c o m
 * 
 * @param v
 */
public void message_post_web_tomain(View v) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(WebdbActivity.this);
    builder1.setTitle("");
    builder1.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder1.setMessage("");
    builder1.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            if (null != webView) {
                webView.goBack();
                finish();
            }
        }
    });
    builder1.setNegativeButton("", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    builder1.show();

}

From source file:mp.paschalis.RequestActivity.java

/**
 * Returns a book to user/*  w w w. ja  v a 2  s  .  com*/
 */
private void hButtonReturnBook() {
    buttonHybrid.setText(R.string.isItReturned_);

    buttonHybrid.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            {
                AlertDialog.Builder alert = new AlertDialog.Builder(RequestActivity.this);
                alert.setTitle(R.string.msgIsItReturnedToYou_);

                alert.setIcon(R.drawable.ic_menu_forward);

                alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() {

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

                alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Return the book
                        new AsyncTaskReturnABook().execute(dataClassActivities.book.isbn);
                    }
                });

                alert.show();

            }

            // DataClassLentABook data = new DataClassLentABook();
            //
            // data.destinationUser = dataClassActivities.username;
            // data.isbn = dataClassActivities.isbn;
            //
            // new AsyncTaskLentABook_Activities().execute(data);

        }
    });

}

From source file:com.moro.synapsemod.MainActivity.java

protected void guardar_perfil() {

    AlertDialog.Builder adb = new AlertDialog.Builder(MainActivity.this);
    adb.setTitle(R.string.dlg_backup_title);
    adb.setIcon(R.drawable.ic_action_save);
    adb.setMessage(R.string.dlg_backup_message);

    final EditText editText = new EditText(MainActivity.this);
    editText.setHint(R.string.dlg_backup_box);
    adb.setView(editText);//  w w w. ja  va 2 s.  co m

    // Si pulsamos OK, cargamos el dialogo de confirmacion de carga de perfil
    adb.setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // Guardamos el perfil
            String name = editText.getText().toString().replace(' ', '_');
            Utils.runCommand(BB + " mount -o remount,rw /", false);
            Utils.runCommand("/res/synapse/actions/sqlite ExportConfigSynapse " + name, false);
            Utils.runCommand(BB + " mount -o remount,ro /", false);

            Toast toast = Toast.makeText(getApplicationContext(),
                    getString(R.string.dlg_bk_profile_toast) + " " + name, Toast.LENGTH_LONG);
            toast.show();
        }
    });
    // Si pulsamos Cancelar salimos
    adb.setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    // create an alert dialog
    AlertDialog alert = adb.create();
    alert.show();
}

From source file:com.tweetlanes.android.view.HomeActivity.java

public void showPromote() {
    final View layout = View.inflate(this, R.layout.promote, null);

    //final EditText promoStatus = ((EditText) layout.findViewById(R.id.promoStatusEditText));
    //promoStatus.setText(R.string.free_for_life_promo_status);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(0);

    builder.setPositiveButton("Agree!", new Dialog.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            TwitterFetchUsers.FinishedCallback callback = TwitterManager.get()
                    .getFetchUsersInstance().new FinishedCallback() {

                        @Override
                        public void finished(TwitterFetchResult result, TwitterUsers users) {

                            if (result.isSuccessful()) {

                                String statusText = getString(R.string.promote_status_text);
                                TwitterStatusUpdate statusUpdate = new TwitterStatusUpdate(statusText);

                                TwitterManager.get().setStatus(statusUpdate,
                                        TwitterManager.get().getFetchStatusInstance().new FinishedCallback() {

                                            @Override
                                            public void finished(TwitterFetchResult result,
                                                    TwitterStatus status) {

                                                if (result.isSuccessful()) {
                                                    showFreeForLifeSuccess();
                                                } else {
                                                    showFreeForLifeError();
                                                }
                                            }
                                        });
                            }/*from   w  w w . j  av  a  2  s . c  o m*/

                        }
                    };

            getApp().triggerFollowPromoAccounts(callback);
        }
    });
    builder.setNegativeButton("Cancel", null);
    builder.setView(layout);
    builder.setTitle("Promote Tweet Lanes!");

    AlertDialog alertDialog = builder.create();
    alertDialog.show();
}

From source file:net.evecom.android.web.Web0Activity.java

/**
 * //  w  w  w  . j a v a 2 s . c om
 * 
 * @param v
 */
public void message_post_web_tomain(View v) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(Web0Activity.this);
    builder1.setTitle("");
    builder1.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder1.setMessage("");
    builder1.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }
    });
    builder1.setNegativeButton("", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    builder1.show();
}