Error with android.graphics.Paint

1

I'm starting with Android and its IDE. I'm following a slightly outdated manual but that most of the things it describes are valid. Then with the description of this error that AndroidStudio gives me, I can not find out the reason for the failure, which I'm sure is nonsense, but I'm a bit lost.

The issue is that I am creating two Paint objects and when I want to modify some of its properties, like color or style, it says:

  • That does not recognize the method.
  • And maybe derived from the first failure, it does not recognize the values that happened to it.

I leave the code I'm working with:

    public class ExtendedEditText extends AppCompatEditText {

    Paint p1 = new Paint(Paint.ANTI_ALIAS_FLAG);
    Paint p2 = new Paint(Paint.ANTI_ALIAS_FLAG);

    p1.setColor(Color.BLACK);//--------> Aquí da error
    p1.setStyle(Paint.Style.FILL);//---> Aquí da error
    p2.setColor(Color.WHITE);//--------> Aquí da error

    public ExtendedEditText(Context context) {
        super(context);
    }

    public ExtendedEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ExtendedEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void onDraw(Canvas canvas) {

    }

}
    
asked by Jaia 23.12.2018 в 17:50
source

0 answers