final ColorPickerDialog d= new ColorPickerDialog(ActivityName.this,0xffffffff); d.setAlphaSliderVisible(true); d.setButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mPaint.setColor(d.getColor()); } }); d.setButton2("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); d.show();
protected void openColorPickerDialog() { final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); String color = getValue(); if (ColorValidator.isValid(color)) { dlg.setColor(color); } dlg.addDialogClosedHandler(new DialogClosedHandler() { public void dialogClosed(DialogClosedEvent event) { if (!event.isCanceled()) { colorTextBox.setValue(dlg.getColor().toUpperCase(), true); } } }); dlg.showRelativeTo(icon); }
public static ColorPickerDialog newInstance(int num) { ColorPickerDialog f = new ColorPickerDialog(); // Supply num input as an argument. Bundle args = new Bundle(); args.putInt("num", num); f.setArguments(args); return f; }
@Override protected void buttonClicked(Widget button) { // remember color when "OK" is clicked if (button == getOkButton()) { color = slPicker.getColor(); } close(button == getCancelButton()); } }
// initialColor is the initially-selected color to be shown in the rectangle on the left of the arrow. // for example, 0xff000000 is black, 0xff0000ff is blue. Please be aware of the initial 0xff which is the alpha. ColorPickerDialog dialog = new ColorPickerDialog(this, 0xff0000ff, new OnAmbilWarnaListener() { // Executes, when user click Cancel button @Override public void onCancel(ColorPickerDialog dialog){ } // Executes, when user click OK button @Override public void onOk(ColorPickerDialog dialog, int color) { // Create an Intent to launch WidgetConfigurationActivity screen Intent intent = new Intent(getBaseContext(), MainActivity.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); // This is needed to make this intent different from its previous intents intent.setData(Uri.parse("tel:/"+ (int)System.currentTimeMillis())); // Creating a pending intent, which will be invoked when the user // clicks on the widget PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); // Getting an instance of WidgetManager AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getBaseContext()); if (flag) { txtNote.setBackgroundColor(color); } else { txtNote.setTextColor(color); }
public void dialogClosed(DialogClosedEvent event) { if (!event.isCanceled()) { colorTextBox.setValue(dlg.getColor().toUpperCase(), true); } } });
private void handleColorSelection(MouseEvent event, Button button, Input input) { final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(closedEvent -> { if (!closedEvent.isCanceled()) { int[] rgb = ColorUtils.getRGB(dlg.getColor()); String color = "#" + dlg.getColor(); input.setValue("rgb("+rgb[0]+","+rgb[1]+","+rgb[2]+");"); } }); dlg.showRelativeTo(ElementWrapperWidget.getWidget(button)); dlg.getElement().getStyle().setBackgroundColor("white"); }
@Override protected void buttonClicked(Widget button) { // remember color when "OK" is clicked if (button == getOkButton()) { color = slPicker.getColor(); } close(button == getCancelButton()); } }
private void handleColorSelection(MouseEvent event, Button button, Input input) { final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(closedEvent -> { if (!closedEvent.isCanceled()) { int[] rgb = ColorUtils.getRGB(dlg.getColor()); String color = "#" + dlg.getColor(); input.setValue("rgb("+rgb[0]+","+rgb[1]+","+rgb[2]+");"); } }); dlg.showRelativeTo(ElementWrapperWidget.getWidget(button)); dlg.getElement().getStyle().setBackgroundColor("white"); }
protected void showColorDialog(final UIObject owner) { if (readOnly) { return; } final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(event -> { if (!event.isCanceled()) { setValue("#" + dlg.getColor(), true); } }); String color = getValue(); if (color.startsWith("#")) { color = color.substring(1, color.length()); } dlg.setColor(color); dlg.showRelativeTo(owner); }