I'm writing an app which changes the background color of the activity each time you press the button. And this is what I have till now. But it is not working! What am I doing wrong?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button) findViewById(R.id.button1);
final View a = findViewById(R.id.m);
final Random color = new Random();
final Paint p = new Paint();
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
p.setARGB(256,color.nextInt(256),color.nextInt(256),color.nextInt(256));
a.setBackgroundColor((p.getColor()));
}
});
}
It's working when I pass a single color, for example a.setBackgroundColor(Color.GREEN);