I want to get the background color of a button
inside a function. I want to check the equality of the color to perform some action. I use PaintDrawer
but its not working.. app crashing... this is my function
void moves(Button bn)
{
if(flag==1)
{
// Toast.makeText(getApplicationContext(),"Exception",Toast.LENGTH_LONG).show();
if (bn.getText().equals("RED") && plyr==1 && mov==0|| mov==1 && bn.getText().equals("RED"))
{
rembr = bn;
Toast.makeText(getApplicationContext(),"Exception"+rembr.getText(),Toast.LENGTH_LONG).show();
mov = 1;
}
else if (bn.getText().equals("GREEN") && plyr == 2 && mov == 0 || mov==1 && bn.getText().equals("GREEN"))
{
Toast.makeText(getApplicationContext(),"Exception GREEN",Toast.LENGTH_LONG).show();
rembr = bn;
mov = 1;
}
else if (mov == 1 && bn.getText() != "RED" && bn.getText() != "GREEN")
{
/*check
adjsnt(lbl, rembr);
end check*/
falsemov=adjsnt(bn, rembr);
if (falsemov == 1)
{
falsemov = 0;
}
else
{
mov = 0;
PaintDrawable drawable = (PaintDrawable) rembr.getBackground();
int temp = drawable.getPaint().getColor();
bn.setBackgroundColor(temp);
bn.setText(rembr.getText());
rembr.setBackgroundColor(Color.LTGRAY);
if (plyr == 1)
{
plyr = 2;
t1.setBackgroundColor(Color.LTGRAY);
t2.setBackgroundColor(Color.GREEN);
}
else
{
plyr = 1;
t2.setBackgroundColor(Color.LTGRAY);
t1.setBackgroundColor(Color.RED);
}
}
}
}
}
Any help would be highly appretiated.