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:net.evecom.android.log.DailyLogLookActivity.java

/**
 * /*  w w w  .  j  a  v  a2  s .  c  o m*/
 */
private String submit() {
    /**  */
    if (btEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (gzsjButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rzlxButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rznrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (years > calendar.get(Calendar.YEAR)) {
        DialogToast("");
        return "";
    } else if (years == calendar.get(Calendar.YEAR)) {
        if (month > calendar.get(Calendar.MONTH) + 1) {
            DialogToast("");
            return "";
        } else if (month == calendar.get(Calendar.MONTH) + 1) {
            if (day > calendar.get(Calendar.DAY_OF_MONTH)) {
                DialogToast("");
                return "";
            }
        }
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogLookActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(DailyLogLookActivity.this, "", "...");

            formSubmit();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
    return "1";
}

From source file:fr.pasteque.client.Configure.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_EXPORT_ID:
        export();//from  ww w.j  ava 2s. c o m
        break;
    case MENU_IMPORT_ID:
        // Get properties file
        // TODO: check external storage state and access
        File path = Environment.getExternalStorageDirectory();
        path = new File(path, "pasteque");
        File file = new File(path, "pasteque.properties");
        FileInputStream fis;
        try {
            fis = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            Toast t = Toast.makeText(this, R.string.cfg_import_file_not_found, Toast.LENGTH_SHORT);
            t.show();
            return true;
        }
        Properties props = new Properties();
        try {
            props.load(fis);
        } catch (IOException e) {
            e.printStackTrace();
            Toast t = Toast.makeText(this, R.string.cfg_import_read_error, Toast.LENGTH_SHORT);
            t.show();
            return true;
        }
        // Load props
        String host = props.getProperty("host", DEMO_HOST);
        String machineName = props.getProperty("machine_name", null);
        String ticketsMode = props.getProperty("tickets_mode", "simple");
        String user = props.getProperty("user", null);
        String password = props.getProperty("password", null);
        String location = props.getProperty("stock_location", "");
        String printDrv = props.getProperty("printer_driver", "None");
        String printModel = props.getProperty("printer_model", "");
        String printAddr = props.getProperty("printer_address", "");
        String printCtxTry = String.valueOf(getPref("printer_connect_try", DEFAULT_PRINTER_CONNECT_TRY));
        // Save
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor edit = prefs.edit();
        edit.putString("host", host);
        edit.putString("machine_name", machineName);
        // Set tickets mode, simple by default
        switch (ticketsMode) {
        case "restaurant":
            edit.putString("tickets_mode", String.valueOf(RESTAURANT_MODE));
            break;
        case "standard":
            edit.putString("tickets_mode", String.valueOf(STANDARD_MODE));
            break;
        default:
            edit.putString("tickets_mode", String.valueOf(SIMPLE_MODE));
            break;
        }
        edit.putString("user", user);
        edit.putString("password", password);
        edit.putString("stock_location", location);
        edit.putString("printer_driver", printDrv);
        edit.putString("printer_model", printModel);
        edit.putString("printer_address", printAddr);
        edit.putString("printer_connect_try", printCtxTry);
        edit.apply();
        Toast t = Toast.makeText(this, R.string.cfg_import_done, Toast.LENGTH_SHORT);
        t.show();
        // Reset activity to reload values
        this.finish();
        Intent i = new Intent(this, Configure.class);
        this.startActivity(i);
        break;
    case MENU_DEBUG_ID:
        AlertDialog.Builder b = new AlertDialog.Builder(this);
        b.setTitle(R.string.cfg_debug_alert_title);
        b.setMessage(R.string.cfg_debug_alert_message);
        b.setIcon(android.R.drawable.ic_dialog_alert);
        b.setNegativeButton(android.R.string.cancel, null);
        b.setPositiveButton(R.string.cfg_debug_alert_continue, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent i = new Intent(Configure.this, Debug.class);
                Configure.this.startActivity(i);
            }
        });
        b.show();
        break;
    }
    return true;
}

From source file:com.hctrom.romcontrol.MainViewActivity.java

private void showThemeChooserDialog() {
    AlertDialog.Builder b = new AlertDialog.Builder(this);
    Adapter adapter = new ArrayAdapter<>(this, R.layout.simple_list_item_single_choice,
            getResources().getStringArray(R.array.theme_items));
    b.setIcon(R.drawable.ic_htc_personalize).setTitle(getString(R.string.theme_chooser_dialog_title))
            .setSingleChoiceItems((ListAdapter) adapter,
                    PreferenceManager.getDefaultSharedPreferences(this).getInt("theme_prefs", 0),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            //Invokes method initTheme(int) - next method based on chosen theme
                            initTheme(which);
                        }//from www .  j  a v  a2 s. co  m
                    });
    AlertDialog d = b.create();
    d.show();
    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = this.getTheme();
    theme.resolveAttribute(R.attr.colorAccent, typedValue, true);

    Button cancel = d.getButton(AlertDialog.BUTTON_NEGATIVE);
    cancel.setTextColor(typedValue.data);
    Button ok = d.getButton(AlertDialog.BUTTON_POSITIVE);
    ok.setTextColor(typedValue.data);
    d.getWindow().setBackgroundDrawableResource(R.drawable.dialog_bg);
    ListView lv = d.getListView();
    int paddingTop = Math.round(this.getResources().getDimension(R.dimen.dialog_listView_top_padding));
    int paddingBottom = Math.round(this.getResources().getDimension(R.dimen.dialog_listView_bottom_padding));
    lv.setPadding(0, paddingTop, 0, paddingBottom);
}

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

private void showStickerDialog() {
    if (stickerDialog == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setIcon(R.drawable.ic_sentiment_satisfied_black_48dp);
        builder.setTitle(getResources().getString(R.string.supersede_feedbacklibrary_sticker_dialog_title));
        builder.setNegativeButton(getResources().getString(R.string.supersede_feedbacklibrary_cancel_string),
                new DialogInterface.OnClickListener() {
                    @Override/*  www  . ja  v  a2 s .  co m*/
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        if (stickerArrayAdapter == null) {
            stickerArrayAdapter = new StickerArrayAdapter(builder.getContext(), stickerIcons, stickerLabels);
        }
        builder.setAdapter(stickerArrayAdapter, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                addSticker(stickerArrayAdapter.getIcons().get(which));
            }
        });
        builder.setCancelable(false);
        stickerDialog = builder.create();
    }
    stickerDialog.show();
}

From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java

@Nullable
private AlertDialog showAlertDialog(String title, String message, DialogInterface.OnClickListener dismisser) {
    final Activity activity = getActivity();
    if (activity == null) {
        return null;
    }/*  w  w w .  j ava  2s . c  om*/

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
    dialogBuilder.setTitle(title);
    dialogBuilder.setMessage(message);
    dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
    dialogBuilder.setPositiveButton(android.R.string.ok, dismisser);

    AlertDialog dialog = dialogBuilder.create();
    dialog.show();
    return dialog;
}

From source file:mp.paschalis.RequestActivity.java

/**
 * Replies to request of user/*  www.j a va  2  s  .co  m*/
 */
private void hButtonReplyRequest() {
    buttonHybrid.setText(R.string.reply);

    buttonHybrid.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            AlertDialog.Builder builder = new AlertDialog.Builder(RequestActivity.this);

            builder.setIcon(R.drawable.ic_menu_info_details);
            builder.setTitle(R.string.replyToRequest);
            builder.setItems(R.array.ArrayRequestReply, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int item) {

                    LentBookActivity.DataClassLentABook d = new LentBookActivity.DataClassLentABook();
                    d.destinationUser = dataClassActivities.username;
                    d.isbn = dataClassActivities.book.isbn;
                    d.answer = "0";
                    if (item == 0)
                        d.answer = "1";

                    new AsyncTaskReplyToRequest().execute(d);

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

        }
    });

}

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

/**
 * //  w w w . ja  v  a  2  s  .c  o  m
 * 
 * @param v
 */
public void message_post_web_tomain(View v) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(Web5Activity.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();
}

From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java

/**
 * Show a dialog message for a given 'Special Event'
 * @param message/*from w  w  w .  j  av a2 s. c o  m*/
 */
private void showSpecialEvent(String message) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setTitle("Special Event");
    dialogBuilder.setMessage(message);
    dialogBuilder.setPositiveButton("OK", null);
    dialogBuilder.setIcon(R.drawable.ic_dialog_alert);
    dialogBuilder.show();
}

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

/**
 * //from  w w  w  . j a  v a2  s .co m
 * 
 * @param v
 */
public void message_post_web_tomain(View v) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(Web4Activity.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();
}

From source file:net.mceoin.cominghome.MainActivity.java

protected void showAbout() {
    // Inflate the about message contents
    @SuppressLint("InflateParams")
    View messageView = getLayoutInflater().inflate(R.layout.about, null, false);

    PackageInfo pi;//from  w ww. j ava2  s . c  o  m
    String version = "";
    try {
        PackageManager pm = this.getPackageManager();
        String pn = this.getPackageName();
        if (pm == null) {
            version = "unknown";
        } else {
            pi = pm.getPackageInfo(pn, 0);
            version = pi.versionName;
        }
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    TextView versionView = (TextView) messageView.findViewById(R.id.about_version);
    versionView.setText(version);

    // When linking text, force to always use default color. This works
    // around a pressed color state bug.
    TextView textView = (TextView) messageView.findViewById(R.id.about_credits);
    int defaultColor = textView.getTextColors().getDefaultColor();
    textView.setTextColor(defaultColor);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.home);
    builder.setTitle(R.string.app_name);
    builder.setView(messageView);
    builder.create();
    builder.show();
}