ボタンを押すたびにアクティビティの背景色を変えるアプリを書いています。そして、これは私が今まで持っているものです。しかし、それは機能していません!私は何を間違っていますか?
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()));
}
});
}
a.setBackgroundColor(Color.GREEN); などの単一の色を渡すと機能します。