Android: Can not get color with use of ColorPicker but can get color after focusing on this view

advertisements

In My Paint application i am going to pick the colour from the colourpicker.

MyApp is like that: This link

Now i am using this class to pick the colour.

the code i use to pick the colour is:

public void pickColour(){
    takePhotoFromCamera = false;
    takePhotoFromGallery = false;
    new UberColorPickerDialog(TWSBIDrawMainActivity.this, this, canvasColor, true).show(); // generats error here
    myView.getVisibility();
}

the Override method fot that picker is:

@Override
public void colorChanged(int color) {
    // TODO Auto-generated method stub
    TWSBIDrawMainActivity.canvasColor = color;
    float hsv[] = new float[3];
    Color.colorToHSV(TWSBIDrawMainActivity.canvasColor, hsv);
}

And i am drawing that colour in MyView class with code:

@Override
    protected void onDraw(Canvas canvas) {

        //canvas.drawColor(0, PorterDuff.Mode.CLEAR);
        // set the Canvas Color
        canvas.drawColor(canvasColor);
 }

Now while i select colourfrom picker then it is selected but when i press on accept it is not going to effect on that view but while i touch on that view then it takes effect.

Instead of that i want is that the colour should be get effect when i press accept from the picker.

Please help me in this. Thanks.

Edited:

Please see this Screen Shot:

Here after opening the dialog if i press the accept button then the colour should be take effect on the white background. but instead of that right now if i press accept button and then if i touch on the white background then only the color take effect. So what should i have to do ?

Hope you got my point. I realy need help of this issue. please help me. . Thanks.


The soln looks like you have to call the invalidate on the view after color is selected.

try myView.invalidate() in colorChanged like

@Override
public void colorChanged(int color) {
    // TODO Auto-generated method stub
    TWSBIDrawMainActivity.canvasColor = color;
    float hsv[] = new float[3];
    Color.colorToHSV(TWSBIDrawMainActivity.canvasColor, hsv);
    myView.invalidate();
}

Here is more help on view