コード例 #1
0
    private void init(Context context, int color) {

      // To fight color branding.
      getWindow().setFormat(PixelFormat.RGBA_8888);

      final LinearLayout mContentView = new LinearLayout(context);
      mContentView.setGravity(Gravity.CENTER);

      mColorPicker = new ColorPickerView(context);

      mContentView.addView(mColorPicker, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

      mContentView.setPadding(
          Math.round(mColorPicker.getDrawingOffset()),
          0,
          Math.round(mColorPicker.getDrawingOffset()),
          0);

      mColorPicker.setOnColorChangedListener(this);
      mColorPicker.setColor(color, true);
      mColorPicker.setAlphaSliderVisible(true);

      setTitle(R.string.pick_color);
      setView(mContentView);

      setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), this);
      setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel), this);
    }
コード例 #2
0
 @Override
 public void onClick(DialogInterface dialog, int which) {
   switch (which) {
     case BUTTON_POSITIVE:
       if (mListener != null) {
         mListener.onColorSelected(mColorPicker.getColor());
       }
       break;
   }
   dismiss();
 }
コード例 #3
0
    public int getColor() {

      return mColorPicker.getColor();
    }
コード例 #4
0
    public void setAlphaSliderVisible(boolean visible) {

      mColorPicker.setAlphaSliderVisible(visible);
    }