1

The background color of my View is #FFFFFFFF. I want to get this through code. I do not want to just put #FFFFFFFF into the method because I will be changing the background through code, so this value will change all the time.

public void toggleEraser() {
    ImageView btnEraser = (ImageView) this.findViewById(R.id.imgEraser);
    ImageView btnBrush = (ImageView) this.findViewById(R.id.imgBrush);
    if (erase) {
        btnEraser.setImageResource(R.drawable.greyeraser);
        btnBrush.setImageResource(R.drawable.brush);
    } else {
        btnEraser.setImageResource(R.drawable.eraser);
        btnBrush.setImageResource(R.drawable.greybrush);
    }
    erase = !erase;
    if (erase){

                    //Here is the problem
        drawView.setColor(//drawView.getBackgroundColor());


    }
    else
        drawView.setColor(brushColor);
    drawView.setErase(erase);
}
Dobz
  • 1,213
  • 1
  • 14
  • 36

2 Answers2

1

Check out this answer: Get the background color of a button in android. it is a little different but can lead you on the right path.

Community
  • 1
  • 1
Parnit
  • 1,032
  • 2
  • 8
  • 16
1

store the color you want 0xFFFFFFFF in somevariable and then change drawView.setColor( to drawView.setBackgroundColor(somevariable);